EM algorithm for zero-inflated Poisson regression (source code)

= EM algorithm for zero-inflated Poisson regression
{c}
{title2=$\tau_i=P(Z_i=1\mid Y_i)$}

The <expectation-maximization algorithm> introduces $Z_i=1$ for a structural zero. Its E-step gives $\tau_i=0$ at positive counts and $\tau_i=\pi_i/[\pi_i+(1-\pi_i)e^{-\mu_i}]$ at zero. The M-step maximizes a logistic <log-likelihood> with fractional responses $\tau_i$ and a Poisson <log-likelihood> with weights $1-\tau_i$. With only a binary predictor, write $n_j$ for group size, $S_j=\sum_{x_i=j}\tau_i$ and $C_j=\sum_{x_i=j}Y_i$; the explicit updates are $\pi_j=S_j/n_j$ and $\mu_j=C_j/(n_j-S_j)$. Log and logit group contrasts recover the regression coefficients, with boundary values interpreted through limits.