20/05/27 17:40:48.61 uX2xSEBS.net
>>197
忘れないようにStanで書いてみた。
################# MCMC by stan ############
stancode='
data {
int<lower=0> n;
vector[n-1] t;
real ln_par1;
real ln_par2;
}
parameters {
real<lower=0> x_incub[n];
}
model {
target += lognormal_lpdf(x_incub|ln_par1,ln_par2);
}
generated quantities{
real x_infected[n];
x_infected[1]= -x_incub[1];
for(i in 2:n){
x_infected[i] = sum(t[1:(i-1)]) - x_incub[i];
}
}
'