# How to implement Zero-Inflated Multinomial?

**URL:** <https://discourse.pymc.io/t/how-to-implement-zero-inflated-multinomial/3961>\
**Category:** Questions\
**Created:** [October 12, 2019, 6:00pm UTC](https://discourse.pymc.io/t/how-to-implement-zero-inflated-multinomial/3961 "2019-10-12T18:00:57Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![AlexAndorra](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/alexandorra/32/9142_2.png) [@AlexAndorra](https://discourse.pymc.io/u/AlexAndorra)\
**Post date:** [October 16, 2019, 3:24pm UTC](https://discourse.pymc.io/t/how-to-implement-zero-inflated-multinomial/3961/4 "2019-10-16T15:24:28Z")

</div>

I got all my data and can confirm that the zero-inflated categories are mostly 3 and 4: 25% of zeros in the sample – category 1’s zero-inflation is near-negligible, with about 5% zeros.  
I read lots of papers, and it seems to be an active area of research! From what I understood, there are two options - none of which I know how to implement in PyMC:

1. Generalizing [Diallo et al.](https://www.sciencedirect.com/science/article/abs/pii/S0378375817301623?via%3Dihub), for every observation i, we assume that given the total C\_{1i} + C\_{2i} + ... + C\_{6i} + C\_{7i} = N\_i, the multinomial response C\_i = (C\_{1i}, C\_{2i}, ..., C\_{7i}) is generated from the model:

\begin{equation} C\_i \sim \begin{cases} (C\_{1i}, C\_{2i}, 0, C\_{4i}, ..., C\_{7i}), & \text{with probability $\pi$}\\ (C\_{1i}, C\_{2i}, C\_{3i}, 0, ..., C\_{7i}), & \text{with probability $\phi$}\\ mult(N\_i, p\_i), & \text{with probability $1- \pi - \phi$} \end{cases} \end{equation}

\text{where}\ p\_i = (p\_{1i}, ..., p\_{7i}) \ \text{and}\ \Sigma\_j(p\_{ji}) = 1

1. Reverse the thinking and model the non-zero-inflated categories (2, 5 and 6) as baseline-inflated: because they were available all the time, some of their numbers are inflated compared to their true proportion, when all categories are available. Thus, following [Cai et al.](https://journals.sagepub.com/doi/abs/10.1177/0049124118782535?journalCode=smra), if p(k|\theta) denotes a multinomial PMF with 7 categories, the model’s likelihood is:

\begin{equation} p(Y\_i = k) = \begin{cases} \pi\_k +(1 - \pi\_2 - \pi\_5 - \pi\_6)\ p(k|\theta), & \text{if $k = 2, 5, 6$}\\ (1 - \pi\_2 - \pi\_5 - \pi\_6)\ p(k|\theta), & \text{otherwise} \end{cases} \end{equation}

where k is the _k_th category in the multinomial distribution, and \pi\_k is the probability of inflation of category k.

I prefer option 1 (more intuitive, less convoluted), but which is easier to implement in PyMC? How would I even go about it?  
A huge thanks in advance for your help 🍾  
_(of course, please tell me if there is any mistake above)_

---

_[View the full topic](https://discourse.pymc.io/t/how-to-implement-zero-inflated-multinomial/3961)._
