% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methods_post_estimation.R
\name{bayes_factor}
\alias{bayes_factor}
\title{Calculate Bayes Factor}
\usage{
bayes_factor(logml1, logml2, error_threshold = 0.2)
}
\arguments{
\item{logml1}{The first model fit (e.g., `mcmc_fit`) or its log-marginal likelihood.}

\item{logml2}{The second model fit (e.g., `mcmc_fit`) or its log-marginal likelihood.}

\item{error_threshold}{Threshold for warning about high bridge-sampling error (default 0.2).}
}
\value{
An object of class `bayes_factor` containing the Bayes factor, log Bayes factor, 
  approximate estimation error, and interpretation.
}
\description{
Compare two models by calculating the Bayes Factor based on their
marginal likelihoods.
}
\examples{
\donttest{
  # 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)
}
}
