Error in BioGeoBEARS Analysis

120 views
Skip to first unread message

Aniket Vaibhav Ranjangaonkar

unread,
Aug 19, 2024, 9:09:43 AM8/19/24
to bioge...@googlegroups.com
Hi Nick and everyone! 

I hope this message finds you well. I am writing to seek your expertise and guidance regarding an issue I encountered while running an analysis in BioGeoBEARS. I am currently working on a project involving 57 species of freshwater mussels distributed across four areas. As a beginner-level user of BioGeoBEARS, I greatly appreciate any insights you might provide. The error I encountered is as follows:

FATAL ERROR IN calc_loglike_sp_stratified(). grand_total_likelihood=NA.
These rows of 'all_relative_probs_of_each_state' had NAs:
102,

One possible cause of this: your dispersal matrix may be too restrictive; try changing
e.g. the 0 values to e.g. 0.0000001.  Good luck!

Error in bears_optim_run(BioGeoBEARS_run_object) :
  STOP ERROR #2 in bears_optim_run(). Test calculation of the likelihood with calc_loglike_for_optim_stratified() returned LnL=NaN, which is not a valid starting likelihood. Probably, you have an overly constrained analysis and have thus made your data impossible. For example, if your tips had ranges A and B, but you disallowed the state AB, then your data would be impossible under DEC, because AB is a required intermediate state. Try removing some of the areas allowed/area adjacency/manual states list constraints.  You can also try changing manual dispersal multipliers from 0 to some small value (e.g. 0.00001) -- note that this can work on dispersal multipliers, but NOT on area constraints, which have to be 0 or 1.  Have a CAREFUL THINK about what you are doing and why you think the list of ranges should be so constrained - do you actually have a good argument for your constraints?


To address this, I ensured that there are no zeroes in my manual dispersal multipliers matrix and included an areas_allowed matrix with all entries set to 1. I also attempted to run the analysis using only the +J models and even commented out all files related to the time-stratified analysis, yet the same error persists despite technically applying no constraints.

I am attaching all the relevant files for your review:

  • Mussels_R.R: R code for all models
  • Mussels_onlyJ.R: R code for only +J models using dstart and estart values of 0.001
  • Initial phylogeny and geography files: mussels.nwk, geog.data.txt
  • Files for time-stratified analysis: timeperiods.txt, areas_allowed.txt, areas_adjacency.txt, manual_dispersal_multipliers.txt

I would be immensely grateful for any advice or suggestions you could offer to help resolve this issue.

Thank you very much in advance for your time and assistance.

Yours Sincerely, 
Aniket Vaibhav Ranjangaonkar 
Fifth Year (Integrated MSc.)
School of Biological Sciences

areas_adjacency.txt
manual_dispersal_multipliers.txt
areas_allowed.txt
geog.data.txt
mussels_onlyJ.R
mussels_R.R
timeperiods.txt
mussels.nwk

Aniket Vaibhav Ranjangaonkar

unread,
Aug 30, 2024, 3:21:44 AM8/30/24
to bioge...@googlegroups.com, n.ma...@auckland.ac.nz

Nick Matzke

unread,
Aug 30, 2024, 4:02:55 AM8/30/24
to bioge...@googlegroups.com
Sorry for the slow reply -- I figured it out.  The Newick file had branch lengths in units of years, instead of millions of years.  The internal calculations involve matrix exponentials, these work fine for powers of 1, 2, 10, 100, etc.., but may not react well to powers of say, 100,000,000.  

The rates would also matter -- 0.01 dispersal events per million years is a reasonably low number in a typical biogeography analysis, but if that is a per-year rate, then the rate is effectively 10,000 events per million years. 

I tried this revised file (and revised timeperiods.txt), and it works. 

Cheers!
Nick

PS: All that said, consider my advice on the "areas allowed" and "area adjacency" options, they function but are only useful in very simple cases:


Manually modifying the list of states/ranges — A BETTER SOLUTION than the areas-adjacency matrix

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/CAKSQeKksrpLg5dMrRG0Kt%3DeCVzDNnLKshkMTX-hfNbGe8PE1KA%40mail.gmail.com.
timeperiods.txt
mussels.nwk
mussels_inMy.nwk

Aniket Vaibhav Ranjangaonkar

unread,
Aug 30, 2024, 5:45:19 AM8/30/24
to bioge...@googlegroups.com

Dear Nick,

Thank you very much for your support.

I appreciate the insight regarding the Newick file having branch lengths in units of years instead of millions of years. I had suspected this might cause issues but wasn’t sure exactly how it would affect the calculations or how to make the conversion to Mya. Your explanation has clarified this for me. I will also take your advice and manually modify the list of states rather than relying on the areas-adjacency matrix. Thanks again for your help!

Best regards,

Aniket


Reply all
Reply to author
Forward
0 new messages