BVARResult.marginal_likelihood#
- BVARResult.marginal_likelihood()[source]#
The closed-form log marginal likelihood as a comparable record.
Wraps
log_marginal_likelihoodin aMarginalLikelihoodSelectionso it can sit in onecompare()table beside simulated estimates – Chib, modified harmonic mean, bridge sampling – from the Gibbs and particle-chain members of the family. The record carries the value withmcse=0.0andmethod="analytic", because the number is exact: it uses no draws (n_draws=0) and has no Monte Carlo error. Itssourceis"BVAR({order}), {prior_label}", so two fits of the same order under different priors remain distinguishable in a table, and itsnobsisnobs, whichcompare()checks across records: a fit of a different order scores a different number of observations and is not comparable on this number without adjustment.Differences of the log value across records fitted to the same sample are log Bayes factors;
compare()converts them to posterior model probabilities under the prior model probabilities it is given.- Return type:
_MarginalLikelihoodSelection- Returns:
The record –
log_value,mcse,method,n_draws,source, andnobs.
Example
>>> import numpy as np >>> from cultivars.multivariate.large_dim.bayesian import BVAR >>> from cultivars.bayes.evidence import compare >>> from cultivars.bayes.priors import NormalInverseWishartPrior >>> rng = np.random.default_rng(0) >>> y = np.zeros((120, 2)) >>> for t in range(1, 120): ... y[t] = 0.7 * y[t - 1] + rng.standard_normal(2) >>> res = BVAR(y, order=1).fit(n_draws=200, seed=0) >>> record = res.marginal_likelihood() >>> record.method, record.mcse, record.n_draws ('analytic', 0.0, 0) >>> record.log_value == res.log_marginal_likelihood True >>> record.source 'BVAR(1), niw(l1=0.2, l3=1, l4=100)'
Rank two priors on the same sample:
>>> alt = BVAR(y, order=1, prior=NormalInverseWishartPrior(tightness=0.02)) >>> table = compare(record, alt.fit(n_draws=200, seed=0).marginal_likelihood()) >>> table.rows[0][0] 'BVAR(1), niw(l1=0.2, l3=1, l4=100)'
See also
compare()– the table, with Kass and Raftery’s reading of the Bayes factors.HierarchicalBVAR– maximizes this number over the prior’s hyperparameters rather than comparing a hand-picked few.marginal_likelihood(),bridge_sampling(),modified_harmonic_mean()– simulated estimates for results without a closed form.
References
Kass, R. E., & Raftery, A. E. (1995). Bayes factors. Journal of the American Statistical Association, 90(430), 773-795.
Giannone, D., Lenza, M., & Primiceri, G. E. (2015). Prior selection for vector autoregressions. Review of Economics and Statistics, 97(2), 436-451.