knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 6 )
The brglm2 R package provides the brnb()
function for fitting negative binomial regression models (see @agresti:15, Section 7.3, for a recent account on negative binomial regression models) using either maximum likelihood or any of the various bias reduction and adjusted estimating functions methods provided by brglmFit()
(see ?brglmFit
for resources).
This vignette demonstrates the use of brnb()
and of the associated methods, using the case studies in @kenne:20.
@magolin:89 provide data from an Ames salmonella reverse mutagenicity assay. The response variable corresponds to the number of revertant colonies observed (freq
) on each of three replicate plates (plate
), and the covariate (dose
) is the dose level of quinoline on the plate in micro-grams. The code chunk below sets up a data frame with the data from replicate 1 in @magolin:89[, Table 1].
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) plate <- rep(1:3, each = 6) (salmonella <- data.frame(freq, dose, plate))
The following code chunks reproduces @kenne:20[, Table 2] by estimating the negative binomial regression model with log link and model formula
ames_f <- freq ~ dose + log(dose + 10)
using the various estimation methods that brnb()
supports.
library("brglm2") ames_ML <- brnb(ames_f, link = "log", data = salmonella, transformation = "identity", type = "ML") ## Estimated regression and dispersion parameters est <- coef(ames_ML, model = "full") ## Estimated standard errors for the regression parameters sds <- sqrt(c(diag(ames_ML$vcov.mean), ames_ML$vcov.dispersion)) round(cbind(est, sds), 4)
The following code chunks updates the model fit using asymptotic mean-bias correction for estimating the model parameters
ames_BC <- update(ames_ML, type = "correction") ## Estimated regression and dispersion parameters est <- coef(ames_BC, model = "full") ## Estimated standard errors for the regression parameters sds <- sqrt(c(diag(ames_BC$vcov.mean), ames_BC$vcov.dispersion)) round(cbind(est, sds), 4)
The corresponding fit using mean-bias reducing adjusted score equations is
ames_BRmean <- update(ames_ML, type = "AS_mean") ## Estimated regression and dispersion parameters est <- coef(ames_BRmean, model = "full") ## Estimated standard errors for the regression parameters sds <- sqrt(c(diag(ames_BRmean$vcov.mean), ames_BRmean$vcov.dispersion)) round(cbind(est, sds), 4)
The corresponding fit using median-bias reducing adjusted score equations is
ames_BRmedian <- update(ames_ML, type = "AS_median") ## Estimated regression and dispersion parameters est <- coef(ames_BRmedian, model = "full") ## Estimated standard errors for the regression parameters sds <- sqrt(c(diag(ames_BRmedian$vcov.mean), ames_BRmedian$vcov.dispersion)) round(cbind(est, sds), 4)
As is done in @kosmidis:2019[, Section 4] for generalized linear models, we can exploit the Fisher orthogonality of the regression parameters and the dispersion parameter and use a composite bias reduction adjustment to the score functions. Such an adjustment delivers mean-bias reduced estimates for the regression parameters and a median-bias reduced estimate for the dispersion parameter. The resulting estimates of the regression parameters are invariant in terms of their mean bias properties under arbitrary contrasts, and that of the dispersion parameter is invariant in terms of its median bias properties under monotone transformations.
Fitting the model using mixed-bias reducing adjusted score equations gives
ames_BRmixed <- update(ames_ML, type = "AS_mixed") ## Estimated regression and dispersion parameters est <- coef(ames_BRmixed, model = "full") ## Estimated standard errors for the regression parameters sds <- sqrt(c(diag(ames_BRmixed$vcov.mean), ames_BRmixed$vcov.dispersion)) round(cbind(est, sds), 4)
The differences between reduced-bias estimation and maximum likelihood are particularly pronounced for the dispersion parameter. Improved estimation of the dispersion parameter results to larger estimated standard errors than maximum likelihood. Hence, the estimated standard errors based on the maximum likelihood estimates appear to be smaller than they should be, which is also supported by the simulation results in @kenne:20[, Section 5].
?brglmFit
and ?brglm_control
contain quick descriptions of the various bias reduction methods supported in brglm2. The iteration
vignette describes the iteration and gives the mathematical details for the bias-reducing adjustments to the score functions for generalized linear models.
If you found this vignette or brglm2, in general, useful, please consider citing brglm2 and the associated paper. You can find information on how to do this by typing citation("brglm2")
.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.