I'm creating a new model and I want to compare this with another model using WAIC. I understand that I need to write a generated quantities block. However, I'm struggling to convert the logsumexp of beta. I would greatly appreciate any leads/help. My model block looks like this:
model {
//prior for phi,b
phi ~ cauchy(0,5);
mu_b ~ normal(0,1);
sigma_b ~ cauchy(0,1);
mu ~ normal(0,1);
sigma ~ cauchy(0,1);
//model
log_b_z ~ normal(0, 1);
theta_raw ~ normal(mu, sigma);
for (i in 1:n) {
vector[number_segments] test;
for (j in 1:number_segments) {
test[j] = beta_lpdf(response[i] | p[j][i]*phi, (1-p[j][i])*phi) + log(prob_segment[j]);
}
target += log_sum_exp(test);
}
}