I would like to build a piecewise pdf which takes in a boolean (1 means the value is missing) and outputs the probability of a value being NaN. I know stan doesn’t have any NaNs so I’m wondering how to create this pdf:

p(s|m) \left\{ \begin{array}{ll} p(s=NaN | m=0) = 0 \\ p(s=NaN | m=1) = 1 \\ p(s=x \in \mathbb{R} ^{+} | m=0) = lognorm(x)\\ p(s=x | m=1) = 0 \end{array} \right.

In pseudo code, something like this…

```
functions {
real<lower=0> lognorm_missing(m, mu, sd){
if (m==0) {
if (x=NaN) return 0;
else return lognorm(mu, sd);
}
else {
if (x=NaN) return 1;
else return 0;
}
}
```