Hi Lior.

I just updated /rateshift/ in /phytools/ on GitHub with these 
adjustments. It seems to work well and will run your dataset without 
failing.

I did observe an odd thing with the two-rate model for your data which 
is that the likelihood surface for the position of the rate-shift seems 
to be totally flat. I don't know what would give your data this 
property. (In fact, I don't know if I could simulate data with this 
attribute if I tried.) I found this result to be so worrying that I took 
your original tree & simulated data containing a single rate shift -- 
but I found that I was able to recover the temporal position of this 
shift without an enormous amount of trouble (though optimization /is/ 
very slow). This suggests that I am not seeing the result of a software 
bug or an idiosyncratic problem with the tree.

To update /phytools/ from GitHub you just need to have the /devtools/ 
CRAN package installed and then run 
/devtools:::install_github("liamrevell/phytools")/ from the command line 
of an interactive session in R.

If you want to try to visualize the likelihood surface for your rate 
shift, you make want to try this /phytools/ function 
/likeSurface.rateshift/. See more information here: 
http://blog.phytools.org/2016/08/function-to-plot-likelihood-surface-for.html. 
Unfortunately, it is also bound to be pretty slow for larger 
phylogenetic trees.

Let us know if this is of help.

Sincerely, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 5/16/2023 11:09 AM, Liam J. Revell wrote:
> CAUTION: EXTERNAL SENDER
>
> Hi Lior.
>
> I'm working on this for you now.
>
> Basically a lot of optimization iterations with /rateshift/ tend to
> fail, so I'm basically doing two things: (1) preventing a failed
> optimization from causing the whole run to fail using /try/; and (2)
> allowing the user to parallelize the multiple optimization iterations
> using /foreach/.
>
> When I get both of these fixes working I'll push the update to the
> /phytools/ GitHub and you can install the package from there.
>
> All the best, Liam
>
> Liam J. Revell
> Professor of Biology, University of Massachusetts Boston
> Web:http://faculty.umb.edu/liam.revell/
> Book: Phylogenetic Comparative Methods in R
> <https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r>
> (/Princeton University Press/, 2022)
>
>
> On 5/16/2023 9:57 AM, Lior Glick wrote:
>> CAUTION: EXTERNAL SENDER
>> Hello,
>> I am trying to run the rateshift function from phytools on a rather
>> large phylogeny (500 species).
>> With nrates=1 (null model) everything works fine. Using nrates=2 also
>> completed successfully, but did not reach convergence:
>>> bm_multi = rateshift(tree, data, nrates=2)
>>>   bm_multi$convergence
>> 0
>>
>> I therefore tried to increase to niter=100, but then I got the
>> following error:
>> Optimization progress:
>> |........Error in solve.default(model2$hessian) :
>>    Lapack routine dgesv: system is exactly singular: U[3,3] = 0
>> Calls: rateshift
>> Execution halted
>>
>> I also tried changing to method='REML' and got a slightly different error:
>> Optimization progress:
>> |............................................................................Error
>> in optimHess(sig2, lik2, tree = tree, x = x) :
>>    non-finite finite-difference value [2]
>> Calls: rateshift
>> Execution halted
>>
>> I saw in an old post
>> <http://blog.phytools.org/2017/10/fix-to-optimization-routine-for-non.html>  
>> that
>> a similar issue was fixed in fit.bd
>> <http://fit.bd/>.
>> Is there any fix for rateshit? Alternatively, has anything similar
>> been implemented in another function/package? Or any other suggestion
>> on how to go around this?
>>
>> Thanks!
>>
>> _______________________________________________
>> R-sig-phylo mailing list -R-sig-phylo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>> Searchable archive athttp://www.mail-archive.com/r-sig-phylo@r-project.org/
>          [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-phylo mailing list -R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive athttp://www.mail-archive.com/r-sig-phylo@r-project.org/
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to