if (FALSE) { # require("logspline")
library(bayestestR)
prior <- distribution_normal(1000, mean = 0, sd = 1)
posterior <- distribution_normal(1000, mean = .5, sd = .3)
(BF_pars <- bayesfactor_parameters(posterior, prior, verbose = FALSE))
as.numeric(BF_pars)
}
if (FALSE) { # require("rstanarm") && require("emmeans") && require("logspline")
# \donttest{
# rstanarm models
# ---------------
contrasts(sleep$group) <- contr.equalprior_pairs # see vingette
stan_model <- suppressWarnings(stan_lmer(
extra ~ group + (1 | ID),
data = sleep,
refresh = 0
))
bayesfactor_parameters(stan_model, verbose = FALSE)
bayesfactor_parameters(stan_model, null = rope_range(stan_model))
# emmGrid objects
# ---------------
group_diff <- pairs(emmeans(stan_model, ~group, data = sleep))
bayesfactor_parameters(group_diff, prior = stan_model, verbose = FALSE)
# Or
# group_diff_prior <- pairs(emmeans(unupdate(stan_model), ~group))
# bayesfactor_parameters(group_diff, prior = group_diff_prior, verbose = FALSE)
# }
}
if (FALSE) { # require("brms") && require("logspline")
# brms models
# -----------
if (FALSE) {
contrasts(sleep$group) <- contr.equalprior_pairs # see vingette
my_custom_priors <-
set_prior("student_t(3, 0, 1)", class = "b") +
set_prior("student_t(3, 0, 1)", class = "sd", group = "ID")
brms_model <- suppressWarnings(brm(extra ~ group + (1 | ID),
data = sleep,
prior = my_custom_priors,
refresh = 0
))
bayesfactor_parameters(brms_model, verbose = FALSE)
}
}
Run the code above in your browser using DataLab