-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for phylolm to DHARMa #129
Comments
Started to address this in https://github.com/florianhartig/DHARMa/tree/129-phylolm |
Hi @florianhartig , I tried to install your dev branch 129-phylolm
but i can not run your test
here is the error:
Can you help me figure out please ? |
Hi, I wanted to know if you managed to build a solution to interpret and use phylolm model. |
Hi all, first of all, to run this, you need to also install an updated version of the phylolm package, this is not yet on CRAN.
I have requested that the phylolm developers push an update to CRAN so that this functionality becomes available directly, see here lamho86/phylolm#27 Second, so far I had implemented phyloglm, but not phylolm, but I have added this now, so now it should work for both models. If everything is installed, it should work now
@MorceletL - the rotation argument should in principle allow you to test if the phylogenetic signal is taken out but also this is highly experimental and I also haven't checked in detail that simulations in phylolm are done properly! Proceed with care! I want to stress that this is all currently untested, so this comes with zero guarantees - if you want to use this, I would make sure with simulated data that the model behaves as expected! |
I have added a new phylogenetic autocorrelation test, you can try
|
Dear Florian, Thank you very much for these update. I've been reading the article you mentionned here, and applied it earlier to my model using the package phylosignal, currently using the same data doesn't give the same results, which is a bit strange (it might be due to the scaling of the residuals implemented in DHARMa).
Secondly, I would like to have your opinion on the residual part of the model. In the case oh phylolm residuals are given raw (i.e. without considering the phylogenetic correlation as explained by @celineane here https://github.com/lamho86/phylolm/issues/3. The best way to have the phylogenetic residuals is to multiply them by the inverse square root of the covariance matrix (function sqrt_OU_covariance().) Thus in the rotation argument of DHARMa::simulateResiduals do you agree that this matrix should be added to verify residuals normality and homoscedasticity of the model ? , or shoudl it be the raw residuals ? It is unclear to know which residuals should be analysed to verify the model, since by definition phylolm should correct residuals for phylogenetic correlation. |
Hi @MorceletL, about the Revell 2010 paper: sorry about this, I just pasted it there as a reminder to look at the methods in this paper, but it has nothing to do with the later code example. Your second question is probably the relevant one: in DHARMa, there are two options to rotate residuals, which are described in https://rdrr.io/cran/DHARMa/man/getQuantile.html:
So, in the example above, I contrast raw quantile with rotated quantile residuals, and you see that the rotated ones look much better. To verify the model, you should definitely use the rotated residuals! phylolm is correcting for phylogenetic correlation when estimating the parameters, but as for all gls, the correlation remains in the residuals unless you explicitly account for it. |
p.s.: unless you use software that allows to condition on the covariance structure, which is not possible for gls, but for some Bayesian implementations or also glmmTMB. See discussion in https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.13971 |
A user requests support for https://github.com/lamho86/phylolm
Perspective for this request: Currently, the package does not allow to simulate from the fitted model, which prevents an easy integration into DHARMa. Support could be added if the package developers implement a simulate function, see here
Interim solution for users that, for some reason, have to urgently use DHARMa with this package: take your fitted model, create a simulate function for this model structure yourself, and then use createDHARMa (see help), this will allow most options of the package to be run. See further comments on support of new packages in here. Note that the vignette has some further comments / examples on creating custom simulation functions and reading them into DHARMa
See also comments here: lamho86/phylolm#27
The text was updated successfully, but these errors were encountered: