View source: R/bayes-diagnostics.R
| bayes_factor | R Documentation |
Computes Bayes factors (ratios of marginal likelihoods) between pairs of estimated DSGE models and converts them to posterior odds ratios when prior model probabilities are supplied. Evidence strength follows the Kass-Raftery (1995) scale.
bayes_factor(..., prior_odds = NULL, method = "harmonic_mean", tau = 0.5)
... |
Two or more objects of class |
prior_odds |
A numeric vector of prior model probabilities (or
unnormalized weights) in the same order as |
method |
Passed to |
tau |
Truncation parameter passed to |
The Bayes factor BF_{12} = p(y|M_1)/p(y|M_2) measures how much
the data prefer model M_1 over M_2. Following Kass and
Raftery (1995), evidence strength is assessed via 2 \log BF_{12}:
| 2 log BF | Evidence for M1 |
| < 0 | Negative (favours M2) |
| 0 to 2 | Not worth more than a bare mention |
| 2 to 6 | Positive |
| 6 to 10 | Strong |
| 10 | Very strong |
When prior_odds is supplied the posterior model probability of
model i is
P(M_i | y) \propto p(y | M_i) \cdot \pi_i
where \pi_i is the (possibly unnormalized) prior weight.
The marginal likelihood estimates are based on the modified harmonic mean
estimator and inherit its limitations (see marginal_likelihood).
Use consistent MCMC settings across all models being compared.
An object of class "dsge_bayes_factor" containing:
log_mlNamed numeric vector of log marginal likelihoods.
nseNumerical standard errors for each log-ML estimate.
bf_matrixMatrix of log Bayes factors
\log BF_{ij} = \log ML_i - \log ML_j.
posterior_probsPosterior model probabilities.
prior_oddsPrior model probabilities used.
model_namesCharacter vector of model labels.
Kass, R. E. and Raftery, A. E. (1995). Bayes factors. Journal of the American Statistical Association, 90(430), 773-795.
marginal_likelihood, bayes_dsge
m1 <- dsge_model(
obs(y ~ lead(y) + u),
state(u ~ rho * u),
start = list(rho = 0.5)
)
m2 <- dsge_model(
obs(y ~ u),
state(u ~ rho * u),
start = list(rho = 0.5)
)
set.seed(1)
y <- cumsum(rnorm(60, sd = 0.1))
dat <- data.frame(y = y)
pr <- list(rho = prior("beta", shape1 = 5, shape2 = 5))
fit1 <- bayes_dsge(m1, dat, pr, chains = 1L, iter = 500L, warmup = 200L)
fit2 <- bayes_dsge(m2, dat, pr, chains = 1L, iter = 500L, warmup = 200L)
bf <- bayes_factor(M1 = fit1, M2 = fit2)
print(bf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.