Facing this error problem “hash mismatch so recompiling; make sure Stan code ends with a blank line” when I run the stan function in r.
model {
tau ~ exponential(0.03);
for (m in 1:M){
y[m] ~ exponential(1/tau);
}
phi ~ normal(0,5);
kappa ~ normal(0,0.5);
mu ~ normal(3.28, kappa); // citation: https://academic.oup.com/jtm/article/27/2/taaa021/5735319
alpha_hier ~ gamma(.1667,1);
ifr_noise ~ normal(1,0.1);
for(m in 1:M){
deaths[EpidemicStart[m]:N[m], m] ~ neg_binomial_2(E_deaths[EpidemicStart[m]:N[m], m], phi);
}
}
generated quantities {
matrix[N2, M] prediction0 = rep_matrix(0,N2,M);
matrix[N2, M] E_deaths0 = rep_matrix(0,N2,M);
{
matrix[N2,M] cumm_sum0 = rep_matrix(0,N2,M);
for (m in 1:M){
for (i in 2:N0){
cumm_sum0[i,m] = cumm_sum0[i-1,m] + y[m];
}
prediction0[1:N0,m] = rep_vector(y[m],N0);
for (i in (N0+1):N2) {
real convolution0 = 0;
for (j in 1:(i-1)) {
convolution0 += prediction0[j, m] * SI[i-j];
}
cumm_sum0[i,m] = cumm_sum0[i-1,m] + prediction0[i-1,m];
prediction0[i, m] = ((pop[m]-cumm_sum0[i,m]) / pop[m]) * mu[m] * convolution0;
}
E_deaths0[1, m]= prediction0[1,m];
for (i in 2:N2){
for (j in 1:(i-1)) {
E_deaths0[i,m] += prediction0[j, m] * f[i-j,m] * ifr_noise[m];
}
}
}
}
}
base.stan (3.6 KB)