Dear Jeremie.

I agree with Julien. If your tree is non-ultrametric or if you use 
different fitting methods ("REML" vs. "ML") then you could obtain 
different results. The other circumstance in which you might have a 
different result is if your estimated value of lambda is outside the 
default bounds of caper (0,1).

Here's an example of how to use the argument 'weights' in nlme::gls to 
fit a PGLS model to a non-ultrametric tree:

data ## data frame with species names as row names
tree ## phylogeny
w <- diag(vcv(tree))[rownames(data)]
fit <- gls(y~x, data=data, correlation=corPagel(1,tree),
        weights=varFixed(~w), method="ML")

phytools has one main function to do PGLS called 'phyl.resid'. I would 
generally recommend using caper or nlme combined with the method 
residuals, but the 'phyl.resid' works so it could be useful to 
doublecheck your results. In this case it would be:

phyl.resid(tree, as.matrix(data[,"x",drop=FALSE]),
        as.matrix(data[,"y",drop=FALSE]), method="lambda")

All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

On 1/17/2020 7:55 AM, Julien Clavel wrote:
> [EXTERNAL SENDER]
> 
> Hello J�r�mie,
> 
> 
> 
> Hard to say without a working example, but here are some hints:
> 
>    *   Check if you�re using the same function to optimize (e.g. ML vs REML)
>    *   Are you comparing the same tests? (t or F tests, type of sums of 
> squares)
>    *   Are you using non-ultrametric trees? In �nlme� for instance, it�s a 
> correlation rather than a covariance structure that is optimized while other 
> approaches are dealing with the covariances. This may produce discrepancies 
> on non-ultrametric trees.
> 
> 
> 
> Cheers,
> 
> 
> 
> Julien
> 
> 
> ________________________________
> De : R-sig-phylo <r-sig-phylo-boun...@r-project.org> de la part de J�r�mie 
> Bardin <jeremiebar...@yahoo.fr>
> Envoy� : vendredi 17 janvier 2020 11:22
> � : r-sig-phylo@r-project.org <r-sig-phylo@r-project.org>
> Objet : [R-sig-phylo] pgls_different_pacakges_different_results
> 
> Hello everyone,
> I did pgls on real data and I tried the 3 common solutions : ape+nlme, caper 
> and phytools. I used BM as model and optimized lambda. I was surprized to get 
> different results especially on intercepts. Lambdas were different but close 
> , and results were still not the same by fixing the same lambda value.
> Then, I tried few simulations by varying the correlation strength between the 
> two variables and the source of the correlation (independent but both 
> simulated on the tree, linearly dependent, these two cases with varying 
> proportion...). The fewer the signal, the bigger the differences of the 
> optimized coefficients. However, sometimes pvalues of coefficients are very 
> small with one package and greater than .5 with another one.
> Have you ever seen such results ? I precise that I am using both three 
> solutions in their most simple form as can be founded on Liam's blog or 
> classical tutos.
> Cheers, J�r�mie.
> 
> ----
> J�r�mie Bardin, Dr.
> 
>   CR2P - Centre de Recherche en Pal�ontologie - ParisSorbonne Universit� - 
> MNHN - CNRS
> Site Jussieu, Tour 46-56, 5�et.
> 4 place Jussieu, 75252 Paris Cedex 05
> tel. +331.44.27.51.77.
> jeremie.bar...@upmc.fr / jbar...@mnhn.fr / jeremiebar...@yahoo.fr
>          [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylo&amp;data=02%7C01%7Cliam.revell%40umb.edu%7C243409cdb2334b05049408d79b3bdd93%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637148553747552573&amp;sdata=Uc%2F%2F1Fz58mJjhMzYnsO%2BN%2BBnjZX3gUtnszSoCosrcUc%3D&amp;reserved=0
> Searchable archive at 
> https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2F&amp;data=02%7C01%7Cliam.revell%40umb.edu%7C243409cdb2334b05049408d79b3bdd93%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637148553747552573&amp;sdata=0%2F1axEbCuFUGyOkpXSQIUR%2BRv6oy37moptoURL3sbfM%3D&amp;reserved=0
> 
>          [[alternative HTML version deleted]]
> 
> 
> _______________________________________________
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylo&amp;data=02%7C01%7Cliam.revell%40umb.edu%7C243409cdb2334b05049408d79b3bdd93%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637148553747572562&amp;sdata=p9%2B3vN%2FXZGKWQu1HpM4ky7JNG%2Fths96FUy4qHbeGXmM%3D&amp;reserved=0
> Searchable archive at 
> https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2F&amp;data=02%7C01%7Cliam.revell%40umb.edu%7C243409cdb2334b05049408d79b3bdd93%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637148553747572562&amp;sdata=hbUh%2F32lbKOzjGenCwRMR6F7qtVeY4fQmWnWefqRupI%3D&amp;reserved=0
> 
_______________________________________________
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