Stratified analyses resulting in unexpected estimates

105 views
Skip to first unread message

Ivan Magalhães

unread,
Aug 24, 2020, 3:26:25 PM8/24/20
to BioGeoBEARS
 Hello everyone

I am relatively new to BioGeoBEARS, but already excited with all the possibilities and flexibility of the package!

I have been able to go through the examples, and also run simple analyses with my own data, and now I am trying to run a stratified analysis. I have been able to load the time periods and run the analysis, but the results are quite unexpected. Only by virtue of loading the time periods and using section_the_tree (and without loading additional distance matrices, etc), the results are quite different from the unconstrained analysis. Not only that, some of the estimates are seemingly wrong: even though the model does not include a J free parameter, some of the estimates are going e.g. from area M to area L without the ancestor going through the ML state as would be expected (compare the nodes highlighted in red in the attached figures spider_stratified and spider_unconstrained).

I thought this could be something specific to my dataset, but I tried to replicate the issue with the Psychotria example data and I have similar results: the estimates are very different in the unconstrained vs. stratified analyses, even though the dispersal probabilities, areas allowed, etc. are exactly the same in both time slices (compare attached Psychotria_DEC_stratified.pdf and Psychotria_DEC_unconstrained.pdf). I also attached the exact same inputs and script of this Psychotria analysis so you can replicate the issue.

My main question is: is this huge effect on the estimates to be expected only by introducing the time slices? And how can the stratified reconstruction give estimates that should NOT be allowed by the model (e.g. a cladogenetic A -> B transition in a model that does not have a J free parameter)?

Many thanks for any clarifications regarding this!
Best regards,
Ivan
--
Dr. Ivan L. F. Magalhaes

Postdoctoral fellow — División Aracnología
Museo Argentino de Ciencias Naturales "Bernardino Rivadavia" 
Av. Ángel Gallardo 470, C1405DJR, Buenos Aires, Argentina

Ivan Magalhães

unread,
Aug 24, 2020, 3:29:45 PM8/24/20
to BioGeoBEARS
And now the files (for some reason the forum did not allow me to attach them in the original post).
Thanks!
Ivan
spider_stratified.jpgspider_unconstrained.jpg

Psychotria_DEC_unconstrained.pdf
Psychotria_DEC_stratified.pdf

Ivan Magalhães

unread,
Aug 24, 2020, 3:31:57 PM8/24/20
to BioGeoBEARS
And the scripts... (it seems Google Groups does not like the .R extension!)
Psychotria.rar

Nick Matzke

unread,
Aug 24, 2020, 8:41:40 PM8/24/20
to bioge...@googlegroups.com
Hi -- for this one, I can see that the log-likelihoods and the parameters are different, so you wouldn't expect the ancestral state estimates to be the same.

The fact that the initial DEC model you show has d=0.01, e=0.01 suggests that the optimizer failed to move off of the default starting values, which are typically d=0.01, e=0.01.  This may be an issue with the optimizer, I believe a few months back we found that changing from

$use_optimix = "GenSA" to
$use_optimix = TRUE

...fixed this.

I know there is another request for help on a time-stratified analysis, I haven't been able to get to complex things however as NZ is back on lockdown at the moment & so the toddler is "sharing" the home office. Hopefully soon!

Cheers!
Nick




--
You received this message because you are subscribed to the Google Groups "BioGeoBEARS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biogeobears...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/biogeobears/7b951bed-0070-4e80-8841-d8357daab20an%40googlegroups.com.

Ivan Magalhães

unread,
Aug 24, 2020, 10:23:57 PM8/24/20
to bioge...@googlegroups.com
Dear Nick

Many thanks for the fast response. You are right that the first run did not achieve an appropriate result, and using $use_optimix = TRUE did fix it. Thanks!

However, the anomalous estimate persists: I can now see that the two runs have identical estimated parameters and likelihoods, but the ancestral range estimates are quite different, and the stratified run results in absurd cladogenetic transitions (e.g. M > L). I also had the same issue with the Psychotria example (you can check the pdfs attached to my last message). Any ideas of what might be happening?

Thanks again and please stay safe!
Best,
Ivan

spider_stratified2.jpg
spider_unconstrained2.jpg

Nick Matzke

unread,
Aug 27, 2020, 1:21:56 AM8/27/20
to bioge...@googlegroups.com
Hi Ivan,

Thanks very much for persisting with this -- there was indeed a bug, it was in the uppass calculations for time-stratified ancestral states, so it caused no differences in the log-likelihoods or parameter inferences.  Ancestral states estimates are in most cases dominated by the downpass calculations also (the information flows from the tips down in the downpass, but from the reconstructed root states up in the uppass), but I should have seen this earlier -- I had previously specifically checked the case of comparing non-stratified and time-stratified calculations, and they worked: http://phylo.wikidot.com/biogeobears-validation#DEC - the bug was exceedingly dumb once I saw it!

To get the bug fix from GitHub:

library(devtools)
devtools::install_github(repo="nmatzke/BioGeoBEARS", INSTALL_opts="--byte-compile")

PS: Pasted below, I have the Psychotria example with non-stratified and time-stratified (with constant 1.0s in the dispersal matrix) models now returning the same ancestral states as each other, and as the validation graphics. Script & input files attached.

image.png
image.png

image.png

image.png

Cheers!
Nick

manual_dispersal_multipliers.txt
script_timestrat_v1.R
script_v1.R
tree.newick
geog.data
timeperiods.txt

Ivan Magalhães

unread,
Aug 27, 2020, 6:42:03 PM8/27/20
to bioge...@googlegroups.com
Dear Nick,

Many thanks for checking so quickly into this. I have already run the analyses again and the issue has been solved, and both non-stratified and stratified runs give the same estimates. Thanks again!!

Best,
Ivan

Daniel Eusebio Quintero Vallejo

unread,
Jun 6, 2023, 7:56:24 PM6/6/23
to BioGeoBEARS
Hi, dear Nick, if I have installed BioGeoBEARS recently in this year, is this bug fixed? I followed the instructions at https://github.com/nmatzke/BioGeoBEARS. Specifically I follow this:

library(devtools) devtools::install_github(repo="nmatzke/BioGeoBEARS")

Thanks!

Nick Matzke

unread,
Jun 7, 2023, 3:00:32 AM6/7/23
to bioge...@googlegroups.com
Hi -- yes, this was fixed back in 2020, and yes it's on GitHub.
Cheers, Nick

Reply all
Reply to author
Forward
0 new messages