Hi,
I was wondering when I specify a prior distribution for a parameter, which is closed to the true value, if I need to specify somewhere else an initial value, based on:
Where would this specification go in the code?
functions {
real[] model3(real t, real[] y, real[] theta,
real[] x_r, int[] x_i) {
real dydt[2];
dydt[1] = theta[1]*y[2]-theta[2]*y[1];
dydt[2] = -theta[3]*y[2];
return dydt;
}
}
data {
int <lower=1> nobs;
real t0;
real y0[2];
real ts[nobs];
int <lower=1> indivs;
real <lower=0> antib[nobs];
//real <lower=1, upper=indivs> subj[nobs];
}
transformed data{
real x_r[0];
int x_i[1] = {indivs};
}
parameters {
real <lower=0> pAB0;
real <lower=0> uAB;
real <lower=0> uASC0;
real <lower=0> sigma;
real <lower=0> sigmapAB;
real <lower=0> sigmauASC;
real <lower=0> rpABmu;
real <lower=0> ruASCmu;
real <lower=0> rpAB[indivs];
real <lower=0> ruASC[indivs];
}
model {
real yhat[nobs,2];
//prior distributions
pAB0 ~ uniform(0,1);
uASC0 ~ uniform(0,1);
rpABmu ~ lognormal(-2, sqrt(4));
uAB ~ lognormal(-1, sqrt(2));
ruASCmu ~ lognormal(-0.1, 0.44);
sigmapAB ~ gamma(4, 2);
sigmauASC ~ gamma(1, 2);
sigma ~ normal(0, 1);
for (j in 1:indivs) {
real theta[3];
theta[1] = exp(pAB0)*exp(rpAB[j]);
theta[2] = uAB;
theta[3] = exp(uASC0)*exp(ruASC[j]);
yhat = integrate_ode_rk45(model3, y0, t0, ts, theta, x_r, x_i);
//likelihood
for (i in 1:nobs) {
antib[i] ~ lognormal(yhat[i,2], sigma);
rpAB[j] ~ normal(rpABmu, sigmapAB);
ruASC[j] ~ normal(ruASCmu, sigmauASC);
}
}
}
generated quantities {
real z_pred[nobs];
for (t in 1:nobs){
z_pred[t] = lognormal_rng(antib[t], sigma);
}
}