# R: How does GLM deal with zeros in Poisson regresion?

How are zeros passed into Poisson regresion? I mean the log of 0 is -infinity, so it shouldn't be able to provide zero counts as the dependent variable. Does it use some kind of analytic technique to expand the domain of log function in this specific point?

Does it negatively impact my regresion estimation in case of many zeros (zero inflated data)?

• Remember that the regression is predicting the mean of the conditional response variable, not a particular value. This is similar to how a logistic regression predicts a probability, even though the observations are discrete outcomes.
– Dave
Feb 3, 2021 at 20:35
• Poisson regression expects zeros because the Poisson distribution produces them. The model is linear in the log of the mean of Y, not in the log of Y. Feb 3, 2021 at 20:35
• @Dave Yes, but i'm interested in details of GLM implementation. If i have some cases when dependent variable is equal to 0, how is GLM able to accept that? There should be some kind of error like: 'only positive values are alowed" - you can't pass 0 to log function. Feb 3, 2021 at 20:40

The likelihood of a Poisson r.v. $$Y_i$$ is the following:

$$\text{L}(\lambda, y_i) = \frac{e^{-\lambda}\lambda^{y_i}}{y_i!}$$

When you maximize the log-likelyhood, this is what the function looks like:

$$\text{LL}(\lambda, y_i) = -\lambda + y_i \log{\lambda} - \log{(y_i!)}$$

And if you differentiate with regards to $$\lambda$$, notice that zeros on $$y_i$$ don't interfere with the calculation. The same applies to a series of r.v., just the summations appear in the process.

When talking about GLMs, an extra component appears due to the necessity of a link function and because GLMs are built on top of the exponential dispersion family of distributions, but then again, none of those end up depending on the value of $$y_i$$ it-self in a log calculation, only the parameter $$\lambda$$.

Another place that can shed light on this possible issue is when calculating the deviance of your Poisson model. Long story short, we only use log-likelihood for computational and algebraic reasons, but what we care is about the likelihood function. The deviance is defined as:

$$\text{D}(y, \hat \lambda) = 2(LL(y,y)-LL(\hat \lambda, y)) = \sum^n_{i=1}d^2(\lambda_i, y_i)$$

Where $$LL(y,y)$$ is the likelihood under the saturated model, $$d^2(\mu_i, y_i)$$ is the deviance component of the $$i$$th observation. For the Poisson case, if you go by the definition under log-likelihood, you won't be able to calculate deviance, nor consequently the deviance residuals, due to the log of zero problem. But if you do the algebraic steps before the calculations, you can arrive at :

$$d^2(\mu_i, y_i) = 2({y_i \log(y_i/\hat \lambda_i) - (y_i- \hat \lambda_i))}$$

if $$y_i > 0$$ and

$$d^2(\mu_i, y_i) = 2{\hat \lambda_i}$$

if $$y_i = 0$$.

Conclusively the issue of zeros in the data in the Poisson regression is not a trouble at all. What can be an issue, statistically, but not computationally, is the presence of too much or too few zeros for a Poisson model to apply. In this case, we have the zero-inflated and zero adjusted models to help a model adjust for that.

• Thank you very much, this is a realy great answer! (+1) Feb 3, 2021 at 21:38