if (.Platform$OS.type != "windows" || .Platform$r_arch != "i386") {
fit <- stan_glm(
mpg ~ wt + cyl,
data = mtcars,
QR = TRUE,
chains = 2,
refresh = 0
)
rsq <- bayes_R2(fit)
print(median(rsq))
hist(rsq)
loo_rsq <- loo_R2(fit)
print(median(loo_rsq))
# multilevel binomial model
if (!exists("example_model")) example(example_model)
print(example_model)
median(bayes_R2(example_model))
median(bayes_R2(example_model, re.form = NA)) # exclude group-level
}
Run the code above in your browser using DataLab