With an unknown overdispersion parameter, the negative binomial is not part of the negative exponential family, so can't be fitted as a standard GLM (or by glm()
). There is a glm.nb()
function in the MASS
package that can help you ...
library(MASS)
glm.nb(y~x, ...)
If you happen to have a known/fixed overdispersion parameter (e.g. if you want to fit a geometric distribution model, which has theta=1
), you can use the negative.binomial
family from MASS
:
glm(y~x,family=negative.binomial(theta=1), ...)
It might not hurt if MASS::glm.nb
were in the "See Also" section of ?glm
...