# Censored Count Data in Stan?

I'm trying to fit a negative binomial regression model in Stan to estimate determinants of fertility. Unfortunately the dependent variable (number of children) is censored at a value of 8, therefore I'd like to take this into account. As explained in the reference manual this would be straight forward if the relevant variable was continous. But as far as I know Stan is unable to work with integer parameters, which would be necessary to follow the instructions of the manual for count data. So is there a way to deal with this?

Thanks!

• It would be helpful if you stated which example it was, or better yet reproduced it here. That manual is not light reading. – shadowtalker Sep 4 '16 at 11:28

## 1 Answer

Let $Z$ be the count variable and $Y$ the censored count variable. I assume the question means that $Y=Z$ if $Z<8$ and $Y=8$ if $Z\geq 8$, and that $Y$ is observed data.

For $y<8$, \begin{equation} P(Y=y \mid \theta) = P(Z=y \mid \theta) \end{equation} and for $y=8$ \begin{equation} P(Y=8 \mid \theta) = P(Z\geq 8 \mid \theta) = 1 - P(Z < 8 \mid \theta) = 1 - \sum_{k=0}^7 P(Z=k \mid \theta), \end{equation} so if you can evaluate $P(Z=k \mid \theta)$ for $k=0,\ldots,7$, you can compute the log-likelihood contribution of $P(Y = y \mid \theta)$ in Stan by considering these two cases.