Fits a negative-binomial GLM by the same alternating scheme as
MASS::glm.nb: an initial Poisson fit, then iterate between a
glm.fit with the current negative.binomial(theta)
family and a theta MLE update until the log-likelihood and
theta converge. Coefficients and theta match
MASS::glm.nb to convergence tolerance.
Usage
morie_glm_nb(
formula,
data,
weights,
init.theta = NULL,
link = "log",
control = stats::glm.control(...),
...
)Arguments
- formula, data
Model formula and data.
- weights
Optional prior weights.
- init.theta
Optional starting
theta.- link
Link (default
"log").- control
A
stats::glm.controlobject.- ...
Passed to
glm.control.
Examples
set.seed(1); n <- 300
x <- rnorm(n)
y <- rnbinom(n, mu = exp(0.3 + 0.9 * x), size = 3)
fit <- suppressWarnings(morie_glm_nb(y ~ x, data = data.frame(y, x)))
coef(fit)
#> (Intercept) x
#> 0.3398887 0.7982631
