I am trying to fit a zero-inflated neg. binomial model. I have many predictors for the count model, but only one for the zero model (Saturday).
#extract variable names for the glm model formula n <- names(data_train)[-c(1:4)] n <- n[! n %in% c("Saturday")] fglm <- as.formula(paste("outcol ~", paste(n[!n %in% "outcol"], collapse = " + "))) #identify which coefficients cannot be estimated and omit these fm1 <- glm.nb(fglm, data = model.frame(data_train[,-c(1:4)])) q <- as.data.frame(model.matrix(fm1)) q <- q[, !is.na(coef(fm1))] q <- q[, -1] q$outcol<- data_train$outcol q$Saturday <- data_train$Saturday #extract variable names for the model formula n <- names(q) n <- n[! n %in% c("Saturday")] f <- as.formula(paste("outcol ~", paste(n[!n %in% "outcol"], collapse = " + "), paste("|",paste( "Saturday", sep = " + ")))) #fit zero-infl model only with coef. that can be estimated fit <- zeroinfl(f, data=q, dist="negbin")
I followed Achim Zeileis's recommendation, on https://stat.ethz.ch/pipermail/r-help/2010-March/230576.html to first fit a neg. binomial model without zero-inflation and exclude the coefficients that cannot be estimated (i.e. that are NA), but I still get the error that the system is singular.
Error in solve.default(as.matrix(fit$hessian)) : system is computationally singular: reciprocal condition number = 2.14623e-23
It still persists even if I do not specifiy the zero model part (and hence the model should be the same as the one fitted with glm.nb), so I guess the problem has to be within the count model part. I just don't know how I can find the variables causing the error.