Poisson distribution: how to calculate the expected number of zeros in the presence of an exposure term

I have a dataset each with a line for different products, a count of sales and a number of days on sale. I estimated a Poisson regression to predict sales with an offset term of number of days on sale, but it was over-dispersed and I'm considering using a zero-inflated model. I used the DHARMa package's testZeroInflation function - my model failed the test and clearly has too many zeros.

However, I would like to verify this for myself manually. This Q&A sets out how to do that for a simple dataset with counts only, and I tried something similar:

length(myData$$sales[myData$$sales==0]))   # number of zero sales
P0 <- ppois(0, mean(myData$$sales / myData$$daysOnSale))
P0 * length(myData$sales) # expected number of zeros given Poisson distribution  This test showed I had far fewer zeros than expected. My interpretation is that this would be correct if the exposure term - daysOnSale - were 1 in all cases, but actually it varies widely: from 1 to several hundred. Is there a (straightforward) way to account for exposure when calculating the expected number of zeros? • Could you post a full account of your data and results. – Martijn Weterings Oct 9 '18 at 14:34 • You can add up the expected zeros for each case, with its individual exposure. – Glen_b Oct 10 '18 at 5:04 1 Answer Well, yes. With $$\lambda=\text{expected number of sales in one day}$$ and $$n=\text{exposure}$$, $$X$$ the total number of sales, then $$X$$ is distributed poisson with expectation $$n\cdot\lambda$$, so $$\mathbb{P}(X=0) = e^{-n\cdot \lambda}$$ • Thanks @kjetilbhalvorsen, so would the final answer be to calculate this probability of observing zero for each row and then sum across the rows? As in, myData$probZeroSales <- exp(-1 * myData$daysOnSale * mean(myData$sales / myData$daysOnSale)), sum(myData$probZeroSales) – Tom Wagstaff Oct 9 '18 at 15:40
• That looks ok... – kjetil b halvorsen Oct 9 '18 at 16:59