marginal_likelihood: Marginal likelihood of an estimated model

View source: R/logml.R

marginal_likelihoodR Documentation

Marginal likelihood of an estimated model

Description

Computes the log marginal likelihood \log p(y) of a Bayesian estimate – the quantity whose differences across models on the same data are log Bayes factors. Two estimators are reported:

Usage

marginal_likelihood(est, taus = seq(0.1, 0.9, by = 0.2))

Arguments

est

A qpm_estimate with method = "bayes".

taus

Truncation probabilities for the modified harmonic mean.

Details

  • Modified harmonic mean (Geweke 1999) from the posterior draws, computed for a range of truncation probabilities; a small spread across truncations indicates a reliable estimate.

  • Laplace approximation at the posterior mode in transformed space (parametrization-invariant because the Jacobian is included), with a numerically differenced Hessian.

Truncated priors created with truncate() are renormalized numerically at construction, so they contribute proper densities here.

Value

An object of class qpm_logml: ⁠$logml⁠ (harmonic-mean estimate, averaged over taus), ⁠$by_tau⁠, ⁠$laplace⁠, and the spread across truncations.

References

Geweke, J. (1999). Using simulation methods for Bayesian econometric models. Econometric Reviews, 18(1), 1-73.

Examples


m <- qpm_model(variables = vars(x = "x"), shocks = shocks(e),
               equations = eqs(x ~ rho * x[-1] + e),
               params = list(rho = 0.5))
obs <- simulate(qpm_solve(qpm_calibrate(m, rho = 0.8)), nsim = 120, seed = 1)
est <- qpm_estimate(m, obs, priors(rho = beta(0.5, 0.2)),
                    iter = 300, chains = 2, seed = 2, verbose = FALSE)
marginal_likelihood(est)


qpmR documentation built on Sept. 29, 2026, 5:10 p.m.