runehaubo / lmerTestR

Repository for the R-package lmerTest
48 stars 9 forks source link

Support for the glmmTMB package #31

Open hugesingleton opened 4 years ago

hugesingleton commented 4 years ago

Dear Authors,

Is it possible, to make the lmerTest able to work with the objects resulting from the glmmTMB? lme4 doesn't handle the user specified residual covariance structures (other than unstructured and semi-compound symmetry via G matrix). glmmTMB is an awesome package - it combines two important capabilities: handles GLM (as lme4) and a set of residual covariance structures (like nlme). It does not offer, however, p-values employing the either Sattertwhite or Kenward-Roger DFs. Only the Wald's procedure is available, which is found to be quite anty-conservative in smaller samples.

It would be just great to add Satt./KW based p-values to glmmTMB.

lme4 and glmmTMB share some of the authors (including Ben Bolker), so maybe the "computational strategies" are at least a little similar and make it possible?

With you package, the glmmTMB would become one of the most important R packages for multi-level modelling.

runehaubo commented 4 years ago

Sorry for the late reply. This is a very interesting suggestion and one that we have been thinking about ourselves but unfortunately we have not yet found the time or funds/opportunity to proceed with such a project. We are hopeful that this will change in the future but don't hold your breath for it...

Cheers Rune

danielinteractive commented 2 years ago

@hugesingleton @runehaubo just to cross-reference, we are now starting to look at this relatively urgently, see discussion in https://github.com/glmmTMB/glmmTMB/issues/536 If you think you could help us please let me or @bbolker know :-)

hugesingleton commented 2 years ago

@danielinteractive Thank you for mentioning. Currently I entirely resigned from this topic. For 90% of my work*, I use marginal models, i.e. the MMRM via nlme::gls, and here the Satterthwaite is available via emmeans (at least approximate). When the assumptions for the gls aren't met, I switch to [double robust or IPW] GEE, and here the DF = Inf anyway (even with the Morel's or others' adjustments for VCOV small samples).

/* I ceased mixed models for most of my work. For general linear models (identity link), the conditional and marginal models have equivalent interpretation, so I can safely stay with GLS/[W/DR]GEE, or nlme::lme + emmeans (Satterthwaite). I can avoid difficult discussions on the source of variability via random effects, convergence problems for including both random intercept + slopes (random intercept alone is highly unrealistic in most of my cases), relationships between them (and GLMMs are sensitive to model misspecification) and can focus only on the residual covariance. In case of GLMM the interpretation between conditional and marginal models is essential, so I still prefer the marginal one and stay with [W/DR]GEE or GLS. When I need to mimic the US along with KR/Satt or I have a strongly unbalanced dataset, then I use the lme4 with random slope + intercepts (e.g. (Time + 1|ID)). When a reviewer insists on KR for compound symmetry (which is often a bad choice in longitudinal trials), I "mimimic" it with random intercepts in lme4, praying for positive correlations (CS != random intercepts in general; we suffered from negative correlations not once, lme4 set them to 0 and biased results). Of course, there are special cases, where the generalized mixed models are necessary in my work, and then glmmTMB or lme4 are my go-to solution (nlme cannot handle GLMM, glmmPQL is biased or too limited). Therefore, I have currently no need for this and focused on different topics.

BTW: you may be interested in: https://people.math.aau.dk/~sorenh/software/pbkrtest/ : "Summer 2020: Kenward-Roger approximation for nlme and gls models has been contributed. Is not in package yet." + https://github.com/hojsgaard/pbkrtest/pull/2

But there's also this message, so I'm confused now:

Prof James Roger
January 2, 2021 at 10:54 am

A long while ago I looked at the R code for lme and gls to see if one could easily add KR style adjustments. I gave up seeing that effectively one needs to rewrite so much additional code and effectively rerun the whole model again. The reason is the parameterization of the covariance matrix. The KR approximation uses a Taylor series expansion based on the Covariance matrix itself, whereas R is using variances and correlations to parameterize. Perhaps there is some clever trick to get around this but I never found it in time. My hat off to those who manage it.

Perhaps a useful note is that the the adjusted values are invariant to reparameterization where the covariance matrix is intrinsically linear, or where the inverse of the covariance matrix is intrinsically linear (i.e. the covariance or its inverse can be expressed linearly even if they are not). This is identified in the second paper (the basis for KR2 in SAS and I think as used by Stata). But this invariance does require inclusion of the extra term accounting for potential bias in the mle of the covariance parameters.[Kenward & Roger, Computational Statistics and Data Analysis 53 (2009) 25832595]

James Roger.

https://thestatsgeek.com/2020/12/30/mixed-model-repeated-measures-mmrm-in-stata-sas-and-r/ /