(1) I added the argument dep.var which can have values
"xy", "x", or "y" and permits
(respectively) the substitution rate of x to depend on
the state of y and vice versa, the rate of x
(only) to depend on the state of y, and, finally, the rate of
y (only) to dependent on the state of x.

(2) I also added the argument model which can have values
"ER", "SYM", or "ARD". This just sets
the substitution model for the individual characters, regardless of whether
or not the rates depend on a second state. So, for instance, if
dep.var="x" and model="ER", then x
will have two rates, depending on the state of y, but these
two rates will be equal in a forward & backward direction.

Note that model="ER" may not correspond with what we often think
of as a correlated evolution model, because under a correlated evolution
model we might think that if trait 1 acquires state "b", for
instance, than trait 2 should also acquire state "b" - but under
an equal rates model "b|a" -> "b|b" may occur at a higher rate
than "a|a" -> "a|b", but that high rate is forced to be equal
to the rate of leaving the correlated states, "b|b" -> "b|a".

Note that although the parameter estimates & likelihoods should be quite
similar, they won't be precisely the same because fitDiscrete
makes
different
default root node prior. The likelihoods should also not be compared.

Finally, we can try the "ER" model as follows, noting the
caveat that I outline above:

Unfortunately, to run dotTree as I have above you may have to
roll-back the internally used package, plotrix. For some reason I've yet to
figure out, the latest plotrix version breaks dotTree (and in
quite a spectacular way). Hopefully I will get to the bottom of it soon.

## here is how to install an archived version of plotrix
install.packages(
"https://cran.r-project.org/src/contrib/Archive/plotrix/plotrix_3.6-1.tar.gz",
type="source")

The data for this exercise were simulated without a correlation,
as follows:

5 comments:

Hi Liam, thanks for this update.I followed your instruction and installed plotrix 3.6-1. However, no dots of traits were shown in the plot (the tree was plotted correctly though) when I used dotTree. I did get a few warning messages: In cos(angles) * radius[circle] + x : longer object length is not a multiple of shorter object length

Hello Liam, I am interested in looking at the association between two categorical traits, one being binary but the other one having more than two states. Does the fitPagel command deal with more than two states characters automatically? In Pagel's "User's Manual for Discrete", we can read that "any trait with more than two states can be represented as a series of binary traits, each one contrasting a group labelled "1" with all of the other traits [...]". Is this implemented in the command already? Thanks,Bruno

About this blog

This web-log chronicles the development of new tools for phylogenetic analyses in the phytools R package. Unless you a reading a very recent page of the blog, I recommend that you install the latest CRAN version of phytools (or latest beta release) before attempting to replicate any of the analyses of this site. That is because the linked functions may be archived, and very likely have been replaced by newer versions.