When fitting a negative binomial model in glmmTMB() using "family=nbinom2", but without specifying the dispersion model, the summary() gives an estimate for the dispersion parameter as "Overdispersion parameter for nbinom2 family (): XX", which represents - as far I understand - the phi value described in the manual (also termed theta in other environments). If a dispersion model is specified with "dispformula=~ ...", the summary() gives the estimates for the "Dispersion model". How do these relate to the phi value? I read in the manual that "phi=exp(eta) (where eta is the linear predictor from the dispersion model)". Does this indicate that these estimates of the Dispersion model appear on the log scale, and to get phi, they must be back-transformed?
glmmTMB: Get phi from dispersion model
3 messages · m@tthi@s@suter m@iii@g oii @groscope@@dmi@@ch, John Maindonald, Ben Bolker
If you specify "dispformula=~1?, the output is the same as when a dispformula is not
specified. Certainly, that is the case for models with a betabinomial error. One can
extract phi as ?phi=sigma(obj)
If you specify
a dispformula with >1 coefficients, then calculate either
coef(HCbb.cll)[['disp?]] ## Gives the coefficients
or
coef(summary(HCbb.cll))[['disp?]] ## Adds SE, etc, information
In both cases a logarithmic link function is used.
The following is a function that I have found useful:
getRho <-
function (obj)
{
mm <- model.matrix(obj$modelInfo$allForm$dispformula, data = obj$frame)
fixdisp <- fixef(obj)[["disp"]]
1/(1 + exp(mm %*% fixdisp))
}
If you just want phi, rather than the intra-class correlation rho (which makes more
intuitive sense to me), just set ?phi = exp(mm %*% fixdisp)?. I think this works
in just the same way with nbinom2 errors, but I have not checked the details.
John Maindonald email: john.maindonald at anu.edu.au<mailto:john.maindonald at anu.edu.au>
On 13/01/2021, at 21:16, matthias.suter--- via R-sig-mixed-models <r-sig-mixed-models at r-project.org<mailto:r-sig-mixed-models at r-project.org>> wrote:
When fitting a negative binomial model in glmmTMB() using "family=nbinom2", but without specifying the dispersion model, the summary() gives an estimate for the dispersion parameter as "Overdispersion parameter for nbinom2 family (): XX", which represents - as far I understand - the phi value described in the manual (also termed theta in other environments). If a dispersion model is specified with "dispformula=~ ...", the summary() gives the estimates for the "Dispersion model". How do these relate to the phi value? I read in the manual that "phi=exp(eta) (where eta is the linear predictor from the dispersion model)". Does this indicate that these estimates of the Dispersion model appear on the log scale, and to get phi, they must be back-transformed? _______________________________________________ R-sig-mixed-models at r-project.org<mailto:R-sig-mixed-models at r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
predict(HCbb.cl,type="disp") might also be useful, or predict(HCbb.cl, type="disp", newdata= ...) where the 'newdata' represents sets of covariates for which you would like to get the predicted dispersion. (The coefficients in the output for a non-trivial dispersion model represent effects on the log-phi scale -- they might be log-dispersion parameters for different groups, e.g. if you used dispformula=~f-1 where f was a factor, or they might represent differences in log-dispersion across groups, or per unit change in a continuous covariate, or ...)
On 1/13/21 3:53 AM, John Maindonald wrote:
If you specify "dispformula=~1?, the output is the same as when a dispformula is not
specified. Certainly, that is the case for models with a betabinomial error. One can
extract phi as ?phi=sigma(obj)
If you specify
a dispformula with >1 coefficients, then calculate either
coef(HCbb.cll)[['disp?]] ## Gives the coefficients
or
coef(summary(HCbb.cll))[['disp?]] ## Adds SE, etc, information
In both cases a logarithmic link function is used.
The following is a function that I have found useful:
getRho <-
function (obj)
{
mm <- model.matrix(obj$modelInfo$allForm$dispformula, data = obj$frame)
fixdisp <- fixef(obj)[["disp"]]
1/(1 + exp(mm %*% fixdisp))
}
If you just want phi, rather than the intra-class correlation rho (which makes more
intuitive sense to me), just set ?phi = exp(mm %*% fixdisp)?. I think this works
in just the same way with nbinom2 errors, but I have not checked the details.
John Maindonald email: john.maindonald at anu.edu.au<mailto:john.maindonald at anu.edu.au>
On 13/01/2021, at 21:16, matthias.suter--- via R-sig-mixed-models <r-sig-mixed-models at r-project.org<mailto:r-sig-mixed-models at r-project.org>> wrote:
When fitting a negative binomial model in glmmTMB() using "family=nbinom2", but without specifying the dispersion model, the summary() gives an estimate for the dispersion parameter as "Overdispersion parameter for nbinom2 family (): XX", which represents - as far I understand - the phi value described in the manual (also termed theta in other environments).
If a dispersion model is specified with "dispformula=~ ...", the summary() gives the estimates for the "Dispersion model". How do these relate to the phi value? I read in the manual that "phi=exp(eta) (where eta is the linear predictor from the dispersion model)". Does this indicate that these estimates of the Dispersion model appear on the log scale, and to get phi, they must be back-transformed?
[[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org<mailto:R-sig-mixed-models at r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models [[alternative HTML version deleted]] _______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models