Hello, I have this error message when I try sampling. I use Rstan and the code is as follows. sorry I cant share my code, but the following is the fake code that I created but very similar.
Any suggestions are appreciated. Thanks.
…
Rejecting initial value:
Gradient evaluated at the initial value is not finite.
Stan can’t start sampling from this initial value.
Initialization between (-2, 2) failed after 100 attempts.
Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] “Error in sampler$call_sampler(args_list[[i]]) : Initialization failed.”
[1] “error occurred during calling the sampler; sampling not done”
modelstring="
data{
int<lower=0> T;
int<lower=0> N;
vector<lower=0> [N] score;
int<lower=0> A[N, T];
int<lower=0> trial[N];
int<lower=0> y1[N,T];
int<lower=0> y2[N,T];
}
parameters{
matrix[1,2] beta;
vector<lower=0> [T] d;
matrix[2,8] ran_trial;
vector<lower=0> [2] s_trial;
}
model {
for (o in 1:2){
beta[1,o] ~ normal(0,100);
s_trial[o] ~ student_t(2,0,1)T[0,];
for(tn in 1:8){
ran_trial[o, tn] ~ normal(0,s_trial[o]);
}}
for(j in 1:T) {
d[j] ~ gamma(0.0001, 0.001);
for (i in 1:N){
y1[i,j] ~ poisson(A[i,j]*exp(beta[1,1]* score[i] +ran_trial[1,trial[i]])*d[j]);
y2[i,j] ~ poisson(A[i,j]*exp(beta[1,2]* score[i] +ran_trial[2,trial[i]])*d[j]);
}}
}
"
sm = stan_model(model_code=modelstring)
stan_data = list(score=mydata$score,trial=as.numeric(mydata$trial),
y1=y1,y2=y2,A=A, N=N, T=T)
fit= sampling(sm, data=stan_data, chains=3,iter=600,warmup=200,thin=2)
[edit: auto-indented code]