DHARMa icon indicating copy to clipboard operation
DHARMa copied to clipboard

Add support for phylolm to DHARMa

Open florianhartig opened this issue 4 years ago • 8 comments

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: https://github.com/lamho86/phylolm/issues/27

florianhartig avatar Nov 25 '19 13:11 florianhartig

Started to address this in https://github.com/florianhartig/DHARMa/tree/129-phylolm

florianhartig avatar Jan 27 '23 10:01 florianhartig

Hi @florianhartig , I want to do exactly what you are working on this branch, I've seen your discussion here, https://github.com/lamho86/phylolm/issues/27

I tried to install your dev branch 129-phylolm

devtools::install_github(repo = "florianhartig/DHARMa", subdir = "DHARMa", ref = "129-phylolm",
 dependencies = T, build_vignettes = T, force = TRUE)

but i can not run your test

set.seed(123456)
tre = rtree(50)
x = rTrait(n=1,phy=tre)
X = cbind(rep(1,50),x)
y = rbinTrait(n=1,phy=tre, beta=c(-1,0.5), alpha=1 ,X=X)
dat = data.frame(trait01 = y, predictor = x)
fit = phyloglm(trait01~predictor,phy=tre,data=dat,boot=100)

summary(fit)
coef(fit)
vcov(fit)

DHARMa::simulateResiduals(fit, plot = T)

here is the error:


Error in nobs.default(fittedModel) : no 'nobs' method is available
In addition: Warning message:
In checkModel(fittedModel) :
  DHARMa: fittedModel not in class of supported models. Absolutely no guarantee that this will work!

Can you help me figure out please ?

albanmathieu-pro avatar Apr 05 '24 11:04 albanmathieu-pro