Hi,
I am very new at Stan and Bayesian inference itself. I was following Michael Betancourt’s lecture named Some Bayesian Modeling Techniques in Stan, and I was trying to replicate his example with data that I have that follows the same structure. I have tried both parametrized and non-parametrized versions and both run pretty quickly and end with really good Rhat values and high n_eff. However, when I look at the generated quantities (see code below) and compared with the actual values it does not look very good. Before getting into more complicated matters I wanted to ask a simple question about priors. In Michael’s code mu is normal(0,10) and sigma is cauchy(0,10) (in the parametrized model below). I have no idea why this values 0,10, I assume it depends on the values of the continuous covariates but I don’t know if I need to transform the values somehow to fit the normal and cauchy values or change these to fit my covariates. I am completely lost with this, so any help would be greatly appreciated.
transformed parameters {
vector [N] alpha_indv;
for (n in 1:N){
alpha_indv[n] = alpha_null + alpha_C1[indv_to_C1[n]]
+ alpha_C2[indv_to_C2[n]]
+ alpha_C3[indv_to_C3[n]]
+ alpha_C4[indv_to_C4[n]]
+ alpha_C5[indv_to_C5[n]];
}
}
model {
beta ~ normal(0,10);
alpha_null ~ normal(mu_alpha_null, sigma_alpha_null);
mu_alpha_null ~ normal(0,10);
sigma_alpha_null ~ cauchy(0,10);
alpha_C1 ~ normal(0,sigma_alpha_C1);
sigma_alpha_C1 ~ cauchy(0,10);
alpha_C2 ~ normal(0,sigma_alpha_C2);
sigma_alpha_C2 ~ cauchy(0,10);
alpha_C3 ~ normal(0,sigma_alpha_C3);
sigma_alpha_C3 ~ cauchy(0,10);
alpha_C4 ~ normal(0,sigma_alpha_C4);
sigma_alpha_C4 ~ cauchy(0,10);
alpha_C5 ~ normal(0,sigma_alpha_C5);
sigma_alpha_C5 ~ cauchy(0,10);
y ~ bernoulli_logit(X'*beta+alpha_indv);
}
generated quantities{
int y_pred[N];
for (n in 1:N) {
y_pred[n] = bernoulli_logit_rng(X'[n]*beta+alpha_indv[n]);
}
}