# NOT RUN {
# }
# NOT RUN {
library(rstanarm)
library(loo)
head(radon)
fit <- stan_lmer(log_radon ~ floor + log_uranium + floor:log_uranium
+ (1 + floor | county), data = radon, cores = 2)
y <- radon$log_radon
yrep <- posterior_predict(fit)
psis <- psislw(-log_lik(fit), cores = 2)
# marginal predictive check using LOO probability integral transform
color_scheme_set("orange")
ppc_loo_pit(y, yrep, lw = psis$lw_smooth)
ppc_loo_pit(y, yrep, lw = psis$lw_smooth, compare = "normal")
# loo predictive intervals vs observations
sel <- 800:900
ppc_loo_intervals(y[sel], yrep[, sel], psis$lw_smooth[, sel],
prob = 0.9, size = 0.5)
color_scheme_set("gray")
ppc_loo_intervals(y[sel], yrep[, sel], psis$lw_smooth[, sel],
order = "median", prob = 0.8, size = 0.5)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab