Closed arklumpus closed 2 years ago
Thank you. I think you're right. Thanks so much for bringing this to my attention. I am doublechecking to make sure I understand that you are correct & then I will fix & push to GitHub & CRAN.
Fixed on GitHub now. Will also update on CRAN soon.
Great, thanks!
Hi, I think there might be a bug in ancestral state estimates made using
make.simmap
, when thepis
are notequal
.Consider the following example:
This is a very simple tree (just two branches with length
1
) with a binary character. Since the branches have the same lengths and the model has equal rates, the likelihood at the root node is identical for the two states. As a result, the posterior reconstruction for the ancestral state of the root should be equal to the prior.However, the output of the previous code is something like:
This might be because lines 248-249 in
make.simmap.R
assign the root node state by multiplying the likelihoodL
by the priorpi
; however, the likelihoods at the root node have already been multiplied bypi
in line 105 offitMk.R
.Indeed,
, which is quite similar to the value I got using the example above (likely within the variability of the simulation process).
If the tree has more than two tips, I think this affects the estimate at all internal nodes, since those incorrect root posteriors are used to draw the initial states for the simulations.
Of course, there is no issue if the
pi
s areequal
, but I think the same problem applies even if the they areestimated
orfitzjohn
, instead of being manually fixed.