| bayes_factor | R Documentation |
Compare two models by calculating the Bayes Factor based on their marginal likelihoods.
bayes_factor(logml1, logml2, error_threshold = 0.2)
logml1 |
The first model fit (e.g., 'mcmc_fit') or its log-marginal likelihood. |
logml2 |
The second model fit (e.g., 'mcmc_fit') or its log-marginal likelihood. |
error_threshold |
Threshold for warning about high bridge-sampling error (default 0.2). |
An object of class 'bayes_factor' containing the Bayes factor, log Bayes factor, approximate estimation error, and interpretation.
# Compare two models using Bayes Factor
data(debate, package = "BayesRTMB")
fit1 <- rtmb_lm(sat ~ talk, data = debate)
fit2 <- rtmb_lm(sat ~ talk + perf, data = debate)
map1 <- fit1$optimize()
map2 <- fit2$optimize()
bf <- bayes_factor(map1, map2)
print(bf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.