my code in pystan
vv=range(0,10)
my_code = """
data {
int<lower=0> J; // number of datas
vector[J] value; // observed values
}
parameters {
//Arrival rate coefs
real<lower=1,upper=10> th11;
//jump dist params
real<lower=1> sigma;
}
model {
int ku[J];
for (i in 1:J)
ku[i] ~ poisson(th11);
for (i in 1:J)
value[i] ~ normal(ku[i], sigma);
}
"""
schools_dat = {'J': 10,
'value':vv}
sm = pystan.StanModel(model_code=my_code)
fit = sm.sampling(data=schools_dat, iter=1000, chains=1)
this code always returns same error:
Rejecting initial value:
Error evaluating the log probability at the initial value.
Exception: poisson_lpmf: Random variable is -2147483648, but must be >= 0! (in āunknown file nameā at line 22)Initialization between (-2, 2) failed after 100 attempts.
how to avoid this?