hi, i meet an issue and need some suggestions.
I would like to replicate the results for rat tumor in BDA chapter 5.1
my model is y_i \sim Binomial(n_i,\theta_i) \\
\theta_i \sim Beta (\alpha, \beta) \\
\pi (\alpha, \beta) = 1
I want to get the value of waic. The Stan codes is as follows,
bb_stan <- '
data {
int<lower = 0> N;
array[N] int n;
array[N] int y;
}
parameters {
real<lower=0> alpha;
real<lower=0> beta;
array[N] real<lower=0, upper=1> theta;
}
model {
for (i in 1:N) {
theta[i] ~ beta(alpha, beta);
}
y ~ binomial(n,theta);
}
generated quantities {
vector[N] log_lik;
for (i in 1:N) {
log_lik[i] = binomial_lpmf(y|n,theta);
}
}
'
write(bb_stan,file ='bb.stan')
data(rat,package = 'bang')
data_for_bb <- list(N = length(rat$n),n = rat$n,y = rat$y)
library(rstan)
fit.bb <- stan(file = "bb.stan", data = data_for_bb)
library(loo)
log_lik <- extract_log_lik(fit.bb, parameter_name = "log_lik", merge_chains = TRUE)
waic(log_lik)
however, the ouput looks like wrong because the SE of waic is zero.