marginaleffects
marginaleffects copied to clipboard
Support: `glmtoolbox::glmgee`
Dear @vincentarelbundock,
Would you, please, consider adding the glmtoolbox package (mostly the glmgee() function; but adding others would be great too!) to marginaleffects?
This package provides the predict() functions for all supported models: (weighted) GEE, GNM, GLM, and 0-inflated models.
A few words on "why"? In my opinion, the glmtoolbox makes a new solid standard for GEE estimation in R. This package offers reliable estimation and lots of tools absent in other packages. The current geepack package seems really abandoned. Not much happens there, old (2-3 year-old) issues remain unclosed, serious bugs are unfixed, the routine often crashes for unstructured covariance, which is a big problem. And conversely, sometimes the system is completely singular, while this one ignores it and fits instead of warning. I know geepack a very popular package and historically among the very first implementations (right after "gee"), but nowadays there are new, reliable implementations with great additions. glmtoolbox is one of them. I am using it at work and wouldn't replace it by anything else, finally not afraid of crashing my session. It's gaining popularity and is now officially supported also by the emmeans, insights and parameters packages.
Thanks for the suggestion. I am very interested in adding support for this, and I will certainly take a look at it. That said, I don't want to make false promises. My day job is crazy these days, so I may not have time to get to this in the near term.
In the meantime, if anyone is interested in giving it a shot, here's a tutorial on how to add models:
https://marginaleffects.com/vignettes/extensions.html
I am very interested in this but don't have the time to work on it at the moment. I hope/plan to come back to this eventually, and would very much welcome a Pull Request if someone wants to make one.
In the meantime, I'll close this issue and consolidate it in the master thread here:
https://github.com/vincentarelbundock/marginaleffects/issues/49
This is not (at all) a sign that I am closing the door to this. I am just trying to keep the issue tracker manageable.
Notes:
model$coefficientsappears to be a matrix. This may be harder to support than I thought.- Sometimes has a dispersion parameter. Not sure what to do in
set_coef(). - Currently, the website doesn't work and the motivation for the package is not exactly clear to me. I'm not sure if this is very popular. Since it seems like this will not work immediately with default methods, I am unlikely to work on this until there is clearer motivation, and perhaps some help.
Simple examples:
library(glmtoolbox)
data(Grass)
fit1 <- gnm(Yield ~ b0 + b1/(Nitrogen + a1) + b2/(Phosphorus + a2) + b3/(Potassium + a3), family=gaussian(inverse), start=c(b0=0.1,b1=13,b2=1,b3=1,a1=45,a2=15,a3=30), data=Grass)
data(spruces)
mod1 <- size ~ poly(days,4) + treat
fit1 <- glmgee(mod1, id=tree, family=Gamma(log), corstr="AR-M-dependent(1)", data=spruces)
data(Trajan)
fit1 <- zeroinf(roots ~ photoperiod, family="nbf(log)", zero.link="logit", data=Trajan)
Thank you very much for your response!
I will ask the author of glmtoolbox for some support here. It's a bit difficult to reach him through email, but I will try.
I understand that for now this package is not on the top of the TODO list, and work on it needs to be postponed. But I would like to very kindly ask you, if possible, to please consider not writing glmtoolbox off yet. I will see what support I can get from Professor @lhvanegasp.
If you have a minute, let me, please, explain my perspective.
While working with glmtoolbox on daily basis at work (clinical trials) I find this package a new "king of GEE", essential for all uses using GEE, because:
-
the geepack package 1) has still errors unfixed for years, 2) including crashing the R session for unstructured covariance pattern in many cases which is truly annoying, 3) often fits "unstable" models while glmtoolbox clearly reports conditioning problems (so small changes may result in much varying estimates), 4) authors say that they didn't abandon it but have no time, so I wouldn't expect any further development from it, 5) the weighting procedure is questionable. This package was good in the past, but now it's too risky and seems effectively abandoned. Only little changes are made to keep this at CRAN.
-
at the same time, the glmtoolbox offers much more tools for a variety of GLM models and the GEE estimated GLM as well, it enables the bias-reduced and df-adjusted standard errors (unlike the others), doesn't crash at unstructured covariance with "waves" (used with missing observations), much better warns against ill-conditioned scenarios, works with the emmeans package, supports a variety of AR* covariance patterns, has tidiers for the broom (so I can use it with mice under the multiple imputation), seems to handle weighting better, offers a lot of information criteria (including the Akaike-type penalized Gaussian pseudo-likelihood criterion (AGPC), so finally I can use something a bit more comparable to standard AIC in MMRM models).
This package is new and almost unknown for just one reason - geepack was the first package after gee (which is also today rarely used) which offered additional tools and flexibility, and returned p-values out of the box. For long years there has been no other package worth replacing, so people learned to use it and put it everywhere in tutorials, books, supported it in their packages. And its popularity only grows, because new people find the old materials and repeat it. It's then circular, you know:
-Any R package for GEE?
-geepack of course.
-Ah, OK! Thanks.
But this does not mean there are no better alternatives, it only needs time to build people's awareness.
If geepack got its well-deserved wide support, my personal opinion is that glmtoolbox deserves it even more. But of course this is only my personal view, as one of its rare (still) users...