# NOT RUN {
library(rstanarm)
library(see)
stan_m0 <- stan_glm(extra ~ 1, data = sleep,
family = gaussian(),
refresh=0,
diagnostic_file = file.path(tempdir(), "df0.csv"))
stan_m1 <- stan_glm(extra ~ group, data = sleep,
family = gaussian(),
refresh=0,
diagnostic_file = file.path(tempdir(), "df1.csv"))
res <- weighted_posteriors(stan_m0, stan_m1)
plot(eti(res))
# With BayesFactor and brms
library(BayesFactor)
library(brms)
BFmods <- anovaBF(extra ~ group + ID, sleep, whichRandom = "ID")
res <- weighted_posteriors(BFmods)[1:3]
plot(eti(res))
# Compare to brms::posterior_average
fit1 <- brm(rating ~ treat + period + carry,
data = inhaler,
save_all_pars = TRUE)
fit2 <- brm(rating ~ period + carry,
data = inhaler,
save_all_pars = TRUE)
res_BT <- weighted_posteriors(fit1, fit2)
res_brms <- brms::posterior_average(fit1, fit2, weights = "marglik", missing = 0)[, 1:4]
plot(eti(res_BT))
plot(eti(res_brms))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab