Rob Lanfear asks:
"A quick question to follow up on your two posts, and some recent discussion on the R list: do you have a good feeling for the quickest implementation to do this on large trees? (Happy to assume for the purposes of this question that I'm O.K. with the stochastic variation in stochastic character mapping, and that I'm not worried about the differences between marginal frequencies and marginal probabilities...)"
I was about to submit a response to the comment directly - but then it occurred to me that other readers might be interested as well.
The fastest in R seems to be ASR using Rich Fitzjohn's package diversitree, although it is a little more difficult to use than what I have in phytools.
Here's some demo code, including simulation, with comments:
# simulate using phytools:
# ASR using rerootingMethod
# ASRs in XX$marginal.anc
# ASR using make.simmap
# (we should ideally increase nsim, if possible)
# ASRs in YY$ace
# ASR using diversitree
# (we needed to convert to numeric)
# constrain to ER model
(**Note that I'm not that experienced with diversitree, so please post corrections if the above was not done properly.)
In theory, rerootingMethod & asr.marginal should give identical estimates for any model in which all qij=qji. make.simmap will give different ancestral state estimates, but these will be highly correlated as nsim is made to be large.