I know Vehtari shows the method that
generated quantities {
vector[N] log_lik;
for (n in 1:N)
log_lik[n] <- bernoulli_logit_log(y[n], beta0 + x[n] * beta);
}
However, now I need something like this:
generated quantities {
vector[N_1+N_2] log_lik;
for (n in 1:N_1) {
log_lik[n] = bernoulli_logit_log(y_1[n], beta0 + x_1[n] * beta);
}
for (n in (N_1+1):(N_1+N_2)) {
log_lik[n] = bernoulli_logit_log(y_2[n], beta0 + x_2[n] * beta);
}
}
But I got the error like this:
Chain 1: Exception: array[uni,…] index: accessing element out of range. index 101 out of range; expecting index to be between 1 and 100.
N_1 = N_2 = 100 in my model.
So my question is that how can I combine the two log_lik’s into one log_lik :) So I can use it to compute LOOIC.
Thanks!