## Example in Saha, K., & Paul, S. (2005). Bias-corrected maximum
## likelihood estimator of the negative binomial dispersion
## parameter. Biometrics, 61, 179--185.
#
# Number of revertant colonies of salmonella data
salmonella <- data.frame(freq = c(15, 16, 16, 27, 33, 20,
21, 18, 26, 41, 38, 27,
29, 21, 33, 60, 41, 42),
dose = rep(c(0, 10, 33, 100, 333, 1000), 3),
observation = rep(1:3, each = 6))
# Maximum likelihood fit with glm.nb of MASS
salmonella_fm <- freq ~ dose + log(dose + 10)
fitML_glmnb <- MASS::glm.nb(salmonella_fm, data = salmonella)
# Maximum likelihood fit with brnb
fitML <- brnb(salmonella_fm, data = salmonella,
link = "log", transformation = "inverse", type = "ML")
# Mean bias-reduced fit
fitBR_mean <- update(fitML, type = "AS_mean")
# Median bias-reduced fit
fitBR_median <- update(fitML, type = "AS_median")
# Mixed bias-reduced fit
fitBR_mixed <- update(fitML, type = "AS_mixed")
# Mean bias-corrected fit
fitBC_mean <- update(fitML, type = "correction")
# Penalized likelihood with Jeffreys-prior penalty
fit_Jeffreys <- update(fitML, type = "MPL_Jeffreys")
# The parameter estimates from glm.nb and brnb with type = "ML" are
# numerically the same
all.equal(c(coef(fitML_glmnb), fitML_glmnb$theta),
coef(fitML, model = "full"), check.attributes = FALSE)
# Because of the invariance properties of the maximum likelihood,
# median reduced-bias, and mixed reduced-bias estimators the
# estimate of a monotone function of the dispersion should be
# (numerically) the same as the function of the estimate of the
# dispersion:
# ML
coef(fitML, model = "dispersion")
1 / coef(update(fitML, transformation = "identity"), model = "dispersion")
# Median BR
coef(fitBR_median, model = "dispersion")
1 / coef(update(fitBR_median, transformation = "identity"), model = "dispersion")
# Mixed BR
coef(fitBR_mixed, model = "dispersion")
1 / coef(update(fitBR_mixed, transformation = "identity"), model = "dispersion")
## The same is not true for mean BR
coef(fitBR_mean, model = "dispersion")
1 / coef(update(fitBR_mean, transformation = "identity"), model = "dispersion")
# \donttest{
## An example from Venables & Ripley (2002, p.169).
data("quine", package = "MASS")
quineML <- brnb(Days ~ Sex/(Age + Eth*Lrn), link = "sqrt", transformation="inverse",
data = quine, type="ML")
quineBR_mean <- update(quineML, type = "AS_mean")
quineBR_median <- update(quineML, type = "AS_median")
quineBR_mixed <- update(quineML, type = "AS_mixed")
quine_Jeffreys <- update(quineML, type = "MPL_Jeffreys")
fits <- list(ML = quineML,
AS_mean = quineBR_mean,
AS_median = quineBR_median,
AS_mixed = quineBR_mixed,
MPL_Jeffreys = quine_Jeffreys)
sapply(fits, coef, model = "full")
# }
Run the code above in your browser using DataLab