# What is the best way to estimate theta and psi for ZeroInflatedPoisson?

**URL:** <https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500>\
**Category:** version agnostic\
**Tags:** modeling\
**Created:** [May 26, 2022, 7:52pm UTC](https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500 "2022-05-26T19:52:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordan.howell2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jordan.howell2/32/1742_2.png) [@jordan.howell2](https://discourse.pymc.io/u/jordan.howell2)\
**Post date:** [May 26, 2022, 7:52pm UTC](https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500/1 "2022-05-26T19:52:24Z")

</div>

Hello,

I need to run a model on a target variable that is ZeroInflatedPoisson. I see from [Discrete — PyMC3 3.11.5 documentation](https://docs.pymc.io/en/v3/api/distributions/discrete.html#pymc3.distributions.discrete.ZeroInflatedPoisson) that the distribution takes parameters theta and psi. I have read that I should estimate theta as `number of samples == 0/number of samples`.

What is the best way to set psi? The document says psi is `Expected proportion of Poisson variates (0 < psi < 1)`. I don’t know know what that means.

Also, how would I use this with a regression model? Is the regression formula used for the parameter theta?

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [May 27, 2022, 3:40am UTC](https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500/2 "2022-05-27T03:40:05Z")

</div>

I think this is backwards. I found [this discussion of the ZIP parameteres](https://discourse.pymc.io/t/zero-inflated-poisson-log-lik/2664/3) helpful.

Theta is the usual rate parameter of a poisson distribution. You can confirm this by direct comparison of the 2nd branch of the ZIP PDF shown on the page you linked, and the PDF of a normal Poisson (which you recover when phi = 1).

So you want to estimate theta as usual in a normal Poisson setup: do some stuff to get `logits`, then set `theta = exp(logits)`.

Psi is related to how many “extra” zeros you want to generate. As noted above, when phi = 1, you get a standard Poisson PDF, so all the zeros in your data are assumed to come from a Poisson. When phi = 0, you are saying that your Poisson process ~~NEVER~~ ONLY generates zeros.

So you could set `psi ~ Beta(1, 1)` if you want to be uninformative, or you could try to look at your data and try to skew it one way or the other, but you’ll probably want to use some kind of beta prior.

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [May 27, 2022, 4:51am UTC](https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500/3 "2022-05-27T04:51:58Z")

</div>

> [@jessegrabowski](#):
>
> When phi = 0, you are saying that your Poisson process NEVER generates zeros,

You are actually saying you can only generate zeros, all draws come from the zero inflated component.

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [May 27, 2022, 5:00am UTC](https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500/4 "2022-05-27T05:00:16Z")

</div>

Yes you are exactly right. I missed the \psi in front of the Poisson process in the x \neq 0 branch of the PDF. Thank you for correcting me.

---

<div class="post-metadata">

**Author:** ![jordan.howell2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jordan.howell2/32/1742_2.png) [@jordan.howell2](https://discourse.pymc.io/u/jordan.howell2)\
**Post date:** [May 27, 2022, 9:48am UTC](https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500/5 "2022-05-27T09:48:50Z")

</div>

Thank you. When you say “logits,” I think of a quantile function to get a probability of a binary outcome. Is that what you mean? How does that reconcile to trying to forecast count data?

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [May 27, 2022, 9:52am UTC](https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500/6 "2022-05-27T09:52:52Z")

</div>

I just mean some quantity you compute in \mathbb R^n before you put it through a linking function. I don’t know what the right word for this is in Bayesian lingo, I took this word “logits” from deep learning literature. Latent variable? Latent value?

---

<div class="post-metadata">

**Author:** ![jordan.howell2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jordan.howell2/32/1742_2.png) [@jordan.howell2](https://discourse.pymc.io/u/jordan.howell2)\
**Post date:** [May 27, 2022, 9:54am UTC](https://discourse.pymc.io/t/what-is-the-best-way-to-estimate-theta-and-psi-for-zeroinflatedpoisson/9500/7 "2022-05-27T09:54:34Z")

</div>

Ha! I get so confused with using the right “lingo”. Thankyou!
