I am a new user of Stan, and am fitting a count data, which I do not know what the distribution is. But:

**Y = 2^(z+1) - alpha**,

where

**alpha ~ Poisson(lambda[z+1])** (corrected 07/10, thanks Bob)

and

**z ~ poisson(theta)**

Y is the count data (chromosome), *z* is a parameter represents the stage of this sample. Most of *z* should be 0,1,2,3… so most of Y should be 2,4,8,16… but occasionally we have 3,5,6,7,…15… and some other numbers. (when alpha !=0 so there is missing of chromosome)

I am defining a customized function *Poipoi* for distribution of alpha (to marginalize integer *z*). But since I do not know the distribution of Y ( I didn’t figure out how to do solve this analytically ), I am still having the issue of this integer parameter *z*.

Any suggestion how to model this kind of data? Thank you so much in advance!

Here is my code. It’s kind of messed up but you will know what I am trying to do. Thank you!!

```
functions {
real Poipoi_lpmf(int alpha, int Z, vector[] lambda, real theta){
vector[Z] lp;
for(z in 1:Z)
lp[z] = poisson_lpmf(z | theta) + poisson_lpmf(alpha | lambda[z]);
return log_sum_exp(lp);
}
}
data {
int N;// total number of samples
int Z; // total number of categories
vector[N] Y; //number of count
}
parameters {
real<lower=0> theta; //categorical distribution parameters (with length)
vector<lower=0>[Z] lambda;
int z[N]; // I know this is wrong
}
transformed parameters{
vector<lower=0>[N] alpha;
for (n in 1:N)
alpha[n] = 2^(z[n]+1)-Y[n]
}
model {
for(n in 1:N)
alpha[n] ~ Poipoi(Z, lambda[z[n]+1], theta);
}
```