Open DrJerryTAO opened 7 months ago
Thanks for the detailed comment. I'm completely on board with adding information to the documentation (would you like to submit a pull request ... ???) I'd like to hold off/think very carefully about making changes that will break back-compatibility. (I'm not saying we shouldn't make those changes, just that we have to consider the pros and cons ...)
I just updated my original post to include issues with ziGamma
which are essentially the same things with Gamma
.
I am not sure what a pull request does and how I can make one. I have not used GitHub extensively.
For compatibility, I think we can print a message when predict(type = 'disp')
and glmmTMB(family = Gamma/ziGamma)
are called, stating changes in predicted dispersion and reported estimates in dispersion model. In the help() pages, change the elements as I listed above.
I (or someone) will work on this when I (or they) have time.
Hi @bbolker, I compared
glm
andglmmTMB
withfamily = Gamma
and found thatglmmTMB
reports same dispersion asMASS::gamma.dispersion(glm())
which appears smaller thanglm()
. This makes standard errors smaller inglmmTMB
and larger inglm()
. This is not documented inglmmTMB
and may make first users wonder why the results can be so different fromglm
.glmmTMB
allows variable dispersion associated with predictors, unlikeglm()
that enforces constant dispersion. This is not emphasized inglmmTMB
help, just like Gaussian family. Mentioning the extended flexibility in glmmTMB over basefamily
infamily_glmmTMB
should be helpful.?sigma.glmmTMB
, sigma = (1/sqrt(shape)) for Gamma, which is tested true. However, it lacks important explanation that sigma = sqrt(dispersion). Also, there is no entry for ziGamma, where sigma = (1/sqrt(shape)) = sqrt(dispersion) also stands for the conditional+dispersion components according to my test example.predict(type = 'disp')
generates sigma = sqrt(dispersion), not dispersion for both Gamma and ziGamma. This will be very confusing and cause many innocent mistakes. A simple fix is to square these predicted values for the predicted dispersion parameter.glmmTMB
dispersion model actually fits log(shape) = log(1/dispersion) = b x for both Gamma and ziGamma. This is not documented anywhere and may cause users to misinterpret the model coefficients. A simple fix is to flip the signs of all estimates, so the dispersion model component will fit log(dispersion) = b x. In this way, a larger linear predictor of the dispersion model is associated with a larger dispersion parameter, a larger scale, and a larger variance.?ziGamma
, details for Gamma wrongly say that phi = dispersion = shape, and var = mu phi. The correct formula under current parameterization should be phi = exp(eta) = shape = 1/dispersion, and var = mu^2 / phi. If coefficient signs in the dispersion model are flipped as suggested above, it should be phi = exp(eta) = 1/shape = dispersion, and var = mu^2 phi. The same holds for ziGamma conditional+dispersion components.help
: Mean = shape scale. Variance = mean scale = shape scale^2 = dispersion mean^2 = mean^2/shape. Shape = 1/dispersion = mean^2 / var. Scale = 1/rate = var/mean = mean/shape = mean * dispersion. Dispersion = 1/shape = sigma^2.Test scripts I used