Error in optimx.check

416 views
Skip to first unread message

Utpal Smart

unread,
Jul 30, 2016, 8:48:56 PM7/30/16
to BioGeoBEARS
Hi Nick,

 - I recently tried to repeat an analysis that I had done several months ago and I now receive an error that I had not encountered before, even though all my files are still the same. I am trying to do a time-stratified analysis :


#Uncomment files you wish to use in time-stratified analyses:
  BioGeoBEARS_run_object$timesfn = "timeperiodsSino.txt"
  BioGeoBEARS_run_object$dispersal_multipliers_fn = "Time_stratified_disepersal_matrix_2.txt"
  #BioGeoBEARS_run_object$areas_allowed_fn = "areas_allowed.txt"
  #BioGeoBEARS_run_object$areas_adjacency_fn = "areas_adjacency.txt"
  #BioGeoBEARS_run_object$distsfn = "distances_matrix.txt"
  # See notes on the distances model on PhyloWiki's BioGeoBEARS updates page.

 - When I check the inputs before running the analysis it seems everything is ok :

> check_BioGeoBEARS_run(BioGeoBEARS_run_object)
Read 9 items
Read 24 items



 - However when I run the analysis I get the following error (highlighted in yellow) :

[1] TRUE
> runslow = TRUE
>   resfn = "Sino_DEC_unconstrained.Rdata"
>   if (runslow)
+   {
+     res = bears_optim_run(BioGeoBEARS_run_object)
+     res   
+    
+     save(res, file=resfn)
+     resDEC = res
+   } else {
+     # Loads to "res"
+     load(resfn)
+     resDEC = res
+   }
Read 9 items
Read 24 items
Read 9 items
Read 24 items

Your computer has 8 cores.


NOTE: Before running optimx(), here is a test calculation of the data likelihood
using calc_loglike_for_optim_stratified() on initial parameter values...
if this crashes, the error messages are more helpful
than those from inside optimx().

     d    e a b x n w u j ysv ys y s v mx01 mx01j mx01y mx01s mx01v mx01r  mf dp fdp  LnL
1 0.01 0.01 0 1 0 0 1 0 0   3  2 1 1 1    0     0     0     0     0   0.5 0.1  1   0 -Inf

calc_loglike_for_optim_stratified() on initial parameters loglike=-Inf



Calculation of likelihood on initial parameters: successful.

Now starting Maximum Likelihood (ML) parameter optimization with optimx()...



Printing any warnings() that occurred during calc_loglike_for_optim_stratified():

Warning message:
In readLines(dispersal_multipliers_fn) :
  incomplete final line found on 'Time_stratified_disepersal_matrix_2.txt'


Results of optimx:::scalecheck() below. Note: sometimes rescaling parameters may be helpful for ML searches, when the parameters have much different absolute sizes. This can be attempted by setting BioGeoBEARS_run_object$rescale_params = TRUE.

$lpratio
[1] 0

$lbratio
[1] 0

Maximizing -- use negfn and neggr
     d    e a b x n w u j ysv ys y s v mx01 mx01j mx01y mx01s mx01v mx01r  mf dp fdp  LnL
1 0.01 0.01 0 1 0 0 1 0 0   3  2 1 1 1    0     0     0     0     0   0.5 0.1  1   0 -Inf

Show Traceback
Rerun with Debug
Error in optimx.check(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower, : Function returned is infinite or NA (non-computable)


I have read the other posts about a similar error message. But in my case, the exact same settings and files worked just fine the first time around. Suggestions?

Thanks!

Nick Matzke

unread,
Jul 30, 2016, 9:05:39 PM7/30/16
to bioge...@googlegroups.com
Hi -- you are getting a log-likelihood of -Inf.  I've actually never seen this before, in BioGeoBEARS.  The likelihood calculations haven't changed, so perhaps you had some change in either operating system or machine settings or some minor change in your files that produced a likelihood so low there was a precision error, likelihood was 0, and log-likelihood was therefore -Infinity.

This kind of thing can happen when there is lots of stratification and constraints, if you do it wrong you can make your data impossible, ie likelihood 0, log-likelihood -Inf.  Usually this can be fixed by setting the 0s in the dispersal matrix to 0.000001 or something similar.

Also, make sure the dispersal matrix file ends with:

=============

END

=============

...to avoid the warning...

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 post to this group, send email to bioge...@googlegroups.com.
Visit this group at https://groups.google.com/group/biogeobears.
To view this discussion on the web visit https://groups.google.com/d/msgid/biogeobears/c53d60ad-83e8-4073-b506-041dde849b3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages