I have count data with lots of zero. I have done a GLM with poisson distribution, and I think that using the zero inflated model might improve the fit. Now my problem, I have been working with SPSS. This does not have the zero inflated model build in, and using the R extension did not work. So I have moved to R completely. But I have problem building the model.

I found the pscl package, which can perform zero-inflated Poisson regression. What I want to test are main effects for variable 1 and variable2 and an interaction between them. Plot is a fixed factor.

First I ran a normal poisson distributed model

mod1 = glm(count ~Plot + var1+var2 + var1*var2, family= poisson)

This worked fine. Now for the zeroinfl.

I checked the ?zeroinfl and I saw some things which confuse me. Namely the use of | and |1.

var1 and var2 have 2 levels, and in my data therefore have a value 1 or 2 as seen below. This is just an example and there are more plots. But every combination of var1 and var2 has the same probability of having count zero.

plot    Var1    Var2    count
1       1        1      0
1       1        2      1
1       2        1      2
1       1        2      0

Now I tried it like this.

zeroinfl(n ~ Plot + var1+var2 + var1*var2|1, data = dat)

But I don't think it is correct. I only get an intercept in the zero distributed output, and not the main effects and interaction. Also the zeroinfl does a normal poisson glm and the values differ from my spss output.

So, can anyone help/give me some tips on how to build the model correctly?

Thank you very much.

  • $\begingroup$ How many observations would be enough for such a model? $\endgroup$
    – user405164
    Jan 17 at 16:39

1 Answer 1


In the zero-inflated, the zero counts can come from either a process that generates zero or a process that generates counts, in your case, it is a poisson. In pscl, after the "|" , you specify how you want to model the process that generates zeros.

A good place to start is this vignette, so I will quote a part from there with some added explanation.

The zero-inflated density is a mixture of a point mass at zero $I_{0} (y)$ and a count distribution $f_{count}(y; x,\beta)$. The probability of observing a zero count is inflated with probability $\pi = f_{zero} (0; z,\gamma)$:

$$f_{zeroinfl}(y; x, z, \beta,\gamma) = f_{zero}(0; z,\gamma) · I_{0}(y) + (1 − f_{zero}(0; z, \gamma)) · f_{count}(y; x, \beta)$$

Normally the model that generates zero, is modelled by a binomial GLM where the mean is

$$\mu_i = \pi_i· 0 + (1 − \pi_i) · \exp(x_i^T\beta)$$

If you want to model the zero part with a similar equation, using the example from the package, you do:

fm_zip2 <- zeroinfl(art ~ . | ., data = bioChemists)

zeroinfl(formula = art ~ . | ., data = bioChemists)

Count model coefficients (poisson with log link):
(Intercept)     femWomen   marMarried         kid5          phd         ment  
   0.640839    -0.209144     0.103750    -0.143320    -0.006166     0.018098  

Zero-inflation model coefficients (binomial with logit link):
(Intercept)     femWomen   marMarried         kid5          phd         ment  
  -0.577060     0.109752    -0.354018     0.217095     0.001275    -0.134114 

For your example, if you do:

zeroinfl(n ~ Plot + var1+var2 + var1*var2|1, data = dat)

You are modeling the zero part to be missing at random with a probability that is constant. If you believe your zero values are also dependent on the other variables, you can do:

zeroinfl(n ~ Plot + var1+var2 + var1*var2|Plot + var1+var2 + var1*var2, data = dat)

But before going to such a complicated model, it makes sense to check whether you have enough observations to model this? And also whether there is reason to model it like this


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.