# How to get fitted values corresponding to when the count data value is zero in R?

The data I am working with can be modelled using a negative binomial regression model. My response variable is discrete count values (including zero). All my predictor variables are categorical data. I am now at the stage where I am looking at model diagnostics. When I look at the fitted values obtained using final.model$fitted.values where final.model is obtained using glm.nb, I get NA values for fits when the corresponding observation in the data is zero. Is this what I should be getting? Is there an argument that I can specify to also account for the zero counts? The model is given as: final.model <- glm.nb(y ~ X1 + X2 + X3 + X4 + X5 + X6, na.action = na.omit, data = dataset) fits <- final.model$fitted.values


y takes interger values from [0, N). X1, X2, X3, X4, and X5 are all categorical variables each with two factor levels, except X3 which has three factor levels. X6 is a discrete variable that takes values from [0, 10].

When I look at the fitted values corresponding to the observation when, e.g. y=0, I get NA.

• No, you should not normally get NA fitted values from glm.nb, even when there are zero count values. To get more help than this, you would need to describe your data in more detail and show the code you have used. – Gordon Smyth Jun 29 '17 at 1:40
• @GordonSmyth please see edits to the main question. I – Mischief_Monkey Jun 29 '17 at 3:48