Skip to contents

Fits a Poisson and a negative binomial regression model, returning the model with the lower Akaike information criterion¹.

Usage

glm.count(formula, data = NULL)

Arguments

formula

Formula for the Poisson model, as for the glm() function.

data

Optional data frame containing model variables.

Value

A fitted object of class glm ± negbin.

Details

Wrapper function for stats::glm() and MASS:glm.nb().

References

  1. Akaike, H., 1974. A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19(6), pp. 716–723.

Examples

library(MASS)
data <- MASS::epil
fit <- glm.count(y ~ trt, data = data)
print(class(fit))
#> [1] "negbin" "glm"    "lm"    
print(AS.format(fit, name = c("(Intercept)", "Treatment")))
#>      [,1]          [,2]                   [,3]     
#> [1,] ""            "IRR (95%CI)"          "p"      
#> [2,] "(Intercept)" "8.58 (6.99 to 10.53)" "< 0.001"
#> [3,] "Treatment"   "0.93 (0.70 to 1.23)"  "0.60"