if (FALSE) { # require("rstanarm") && require("logspline")
if (FALSE) {
library(bayestestR)
prior <- distribution_normal(1000, mean = 0, sd = 1)
posterior <- distribution_normal(1000, mean = 0.5, sd = 0.3)
bayesfactor(posterior, prior = prior, verbose = FALSE)
# rstanarm models
# ---------------
model <- suppressWarnings(rstanarm::stan_lmer(extra ~ group + (1 | ID), data = sleep))
bayesfactor(model, verbose = FALSE)
# Frequentist models
# ---------------
m0 <- lm(extra ~ 1, data = sleep)
m1 <- lm(extra ~ group, data = sleep)
m2 <- lm(extra ~ group + ID, data = sleep)
comparison <- bayesfactor(m0, m1, m2)
comparison
bayesfactor(comparison)
}
}
Run the code above in your browser using DataLab