I’m trying to modify the Stan code used by Facebook’s Prophet. In particular, I want to replace the parametre `delta`

with a new parametre `alpha`

with:

\begin{aligned} \alpha_1 &\sim \mathcal L (0, \tau) \\ X_{i>1} &\sim Ber (S / T) \\ Y_{i>1} &\sim \mathcal L (0, \tau) \\ \alpha_{i>1} &= X_i * Y_i + (1 - X_i) * \alpha_{i -1} \end{aligned}

That is, the first value of `alpha`

is distributed according to a Laplace (double exponential) distribution and all further values of `alpha`

have a mixed distribution where there’s a S/T probability they came from another Laplace distribution and a (T - S) / T probability that they are the same value as the previous `alpha`

.

I looked around for something like this and couldn’t find it, but I found something about modelling a zero-inflated Poisson. Based on that, I wrote the following in my model:

```
model {
...
alpha [1] ~ double_exponential (0, tau);
theta ~ beta (S, T - S);
for (i in 2:T) {
if (alpha [i] == alpha [i - 1]) {
target += log_sum_exp (bernoulli_lpmf (1 | theta) + double_exponential_lpdf (alpha [i] | 0, tau), bernoulli_lpmf (0 | theta));
} else {
target += bernoulli_lpmf (1 | theta) + double_exponential_lpdf (alpha [i] | 0, tau);
}
}
...
}
```

Is that correct? Will that work? If not, what do I do instead?

(I realised while writing this example that I could just model X_i and Y_i explicitly and then use `alpha`

as a transformed parametre, but if there’s a better way to do it I’d still like to.)

Edit:

Okay so I just found out that Stan doesn’t support integer parametres so I can’t model the X_i variable, apparently. How do I work around that?