For a zero-inflated model Poisson model, if you observe y=0, then the likelihood is a mixture:

\begin{align*}
\text{Pr} (0 | p, \lambda) & = \text{Pr} (\text{Zero generating process} | p) * (1) + \text{Pr} (\text{Other Process} | p) \times \text{Pr} (0 | \lambda) \\
& = p + (1 - p) \text{ exp} (- \lambda)
\end{align*}

My understanding is that the probability of observing 0, given that you are in the state that produces zero’s only, is equal to 1. So would use the following code for this term:

```
...
if ( y[i] == 0 ) target += log_mix(p, 1, poisson_lpmf(0 | lambda));
...
```

Why is it then that for any online resource I can find (including for example this Stan workshop) this term is coded as:

```
if ( y[i] == 0 ) target += log_mix(p, 0, poisson_lpmf(0 | lambda));
```

I.e. using zero instead of 1 for the second argument in `log_mix`

? I was wondering if my understanding of the `log_mix`

was incorrect, because the latter implies:

\begin{align*} \text{Pr} (0 | p, \lambda) & = \text{Pr} (\text{Zero generating process} | p) * (0) + \text{Pr} (\text{Other Process} | p) \times \text{Pr} (0 | \lambda) \\ & = (1 - p) \text{ exp} (- \lambda) \end{align*}

Which I think is incorrect. Can anyone explain what am I missing here?