DHARMa icon indicating copy to clipboard operation
DHARMa copied to clipboard

Support for phyr::pglmm

Open florianhartig opened this issue 3 years ago • 5 comments

A user requests support for https://github.com/daijiang/phyr, developed by @daijiang

Perspective for this request: It seems that phyr is implementing a simulate function quite similar to lme4, so in principle, it should be possible to support phyr. In practice, I don't know how fast I will manage to do this.

Interim solution take your fitted model, simulate new data (using simulate), and feed this into createDHARMa - this will allow you to use most DHARMa functions. A code example is here. The vignette has some further comments / examples on creating custom simulation functions and reading them into DHARMa.

Note also that, in principle, you can also fit phylogenetic GLMMs with glmmTMB (which is fully supported).

florianhartig avatar Jan 29 '21 16:01 florianhartig

Thanks @florianhartig

phyr works with DHARMa thanks to @rdinnager, though with limited implementation at this moment. See an example here: https://daijiang.github.io/phyr/articles/phyr_example_empirical.html#model-assumption-checks-1

daijiang avatar Jan 29 '21 16:01 daijiang

Hi @daijiang , thanks for the info, I didn't know that it works already. I'll check this out in more detail and see if we can make the support more "official". Cheers, F

florianhartig avatar Feb 01 '21 18:02 florianhartig

Started test in https://github.com/florianhartig/DHARMa/tree/master/Code/DHARMaPackageSupport/phyr

florianhartig avatar Feb 02 '21 09:02 florianhartig

So, as reported in https://github.com/florianhartig/DHARMa/issues/377, this doesn't seem to be working for Models with with Bayes / INLA.

Based on a quick check, I suspect the problem is that there is no explicit simulate function for pglmm objects - for the MLE fits, the simulate probably still works because the structure of the object is such that falling back on the R default simulate function works - probably this is not the case any more if models are fit with INLA.

@daijiang - what I would propose is to provide an explicit simulate function (i.e. simulate.pglmm) in phyr. This function would then hide the problem that different objects may be underlying for other packages. In principle, it should be possible to simulate from INLA models as well.

florianhartig avatar Apr 30 '23 07:04 florianhartig

Thanks! We will take a look at it later and will follow up on this.

daijiang avatar May 01 '23 19:05 daijiang