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
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?