glm1(y, X, lambda, family = "negative.binomial", weights = rep(1, length(y)),
b.init = NA, phi.init = NA, phi.method = "ML", tol = c(1e-08, .Machine$double.eps),
n.iter = 100, phi.iter = 1)
family
. Negative binomial with unknown overdispersion can be specified as "negative.binomial", and is the default.glmnet
if you want something faster (and possibly rougher as an approximation). The main advantage of the glm1
function is that it has been written to accept any glm family argument (although not yet tested beyond discrete data!), and also the negative binomial distribution, which is especially useful for modelling overdispersed counts.
For negative binomial with unknown overdispersion use "negative.binomial"
, or if overdispersion is to be specified, use negative.binomial(theta)
as in the MASS
package. Note that the output refers to phi=1/theta, i.e. the overdispersion is parameterised such that the variance is mu+phi*mu^2. Hence values of phi close to zero suggest little overdispersion, values over one suggest a lot.glm1path
, glm1
, glm
, family
data(spider)
Alopacce <- spider$abund[,1]
X <- cbind(1,spider$x)
#fit a LASSO-penalised negative binomial GLM, with penalty parameter 10:
ft = glm1(Alopacce,X,lambda=10)
plot(ft$logLs) # a plot of the log-likelihood, each iteration to convergence
coef(ft) # coefficients in the final model
Run the code above in your browser using DataLab