1.14.1. The properties
log_post_kern
mdd/log_post_kern is a property.
theta_draws
mdd/theta_draws is a property.
lb
mdd/lb is a property.
ub
mdd/ub is a property.
maximization
mdd/maximization is a property.
H
Hessian used in the calculation of the laplace approximation. If not provided, finite differences will be used. It is the Hessian of log_post_kern at the mode: negative definite when maximization is true, positive definite otherwise.
subset
mdd/subset is a property.
improper_prior
The estimated parameters without a proper prior (rise.engine.dsge_tools.estim.improper_prior). When not empty the prior is improper, the marginal data density is not defined, and every estimator returns NaN with the reason, as estimate does for the Laplace approximation. Set from the model when the kernel is a RISE model; set it yourself for a kernel of your own.
prior_normalizer
The normalizing constant of a prior that combines estim_priors and estim_var_prior on related parameters (rise.engine.dsge_tools.estim.prior_normalizer): log_Z, its Monte Carlo standard error mcse, the number of draws, and the reason when it is not defined (every estimator then returns NaN, with the warning rise:mdd:noPriorNormalizer). The kernel of a RISE model has log_Z out of its log prior already, so the estimators are those of the normalized prior; add mcse to their own Monte Carlo error. Set from the model when the kernel is a RISE model.
thecoef
mdd/thecoef is a property.
1.14.2. The methods
bridge
BRIDGE Computes the log marginal data density using the “bridge” approximation by [Meng and Wong, 1996].
log_mdd=BRIDGE(obj) log_mdd=BRIDGE(obj,fix_point) log_mdd=BRIDGE(obj,fix_point,opts)Args:
obj [mdd]: Marginal Data Density object
fix_point [{true}|false|empty]: if true, optimization is done using a fix point algorithm. Else, an iterative strategy is used.
opts [empty|struct]: options see help for mdd.global_options
- Returns:
:
log_mdd [numeric]: log marginal data density
extras [struct]: history of log MDD and convergences at each iteration, and whether the iterations converged (bridge_converged)
Note:
The iterative strategy (fix_point=false) stops after mdd_bridge_maxiter iterations at most. When it has not converged by then (or when it cannot, the iterates being NaN), it returns the last iterate with a warning, and bridge_converged is false.
See also
mdd.laplace, mdd.mhm, mdd.is, mdd.ris, mdd.cj, mdd.mueller, mdd.laplace_mcmc, mdd.swz, mdd.global_options
cholesky_weighting
- mdd.cholesky_weighting is a function.
[loglik, v_iF_v, lik] = mdd.cholesky_weighting(v, logdet_Sigma, Shat)
The log density of a zero-mean normal at the columns of
v, the weighting of the estimators that use a normal proposal.Shatis the lower Cholesky factor of the covariance matrix (Shat*Shat'=Sigma) andlogdet_Sigmathe logarithm of its determinant, twice the sum of the logs of the diagonal ofShat: the quadratic formsv_iF_vare solved against the factor, and no determinant or inverse is formed, which under- or overflow for many parameters or small variances.normal_weightingis the same from the determinant and the inverse.
cj
CJ Computes the log marginal data density using the [Chib and Jeliazkov, 2001] approximation
log_mdd=CJ(obj) log_mdd=CJ(obj,[],opts)Args:
obj [mdd]: Marginal Data Density object
opts [empty|struct]: options see help for mdd.global_options
- Returns:
:
log_mdd [numeric]: log marginal data density
See also
mdd.laplace, mdd.mhm, mdd.is, mdd.ris, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.swz, mdd.global_options
global_options
GLOBAL_OPTIONS : generic options for the control of computations for Marginal Data Density calculations. Key options include
center_at_mean [{false}|true]: if true, in the calculation of moments, the covariance is centered at the mean, otherwise it is centered at the mode.
L [{500}|empty|integer]: number of extra draws
debug [{false}|true]: displays certain messages for debugging purposes (algorithm specific)
draws_are_iid [{false}|true]:
mdd_bridge_TolFun [{sqrt(eps)}|positive scalar]: convergence tolerance for the bridge sampler’s fixed-point loop.
mdd_bridge_maxiter [{1000}|positive integer]: maximum number of iterations for the bridge sampler’s fixed-point loop.
See also
mdd.laplace, mdd.mhm, mdd.is, mdd.ris, mdd.cj, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.swz
is
IS Computes the log marginal data density using the “importance sampling” approximation
log_mdd=IS(obj) log_mdd=IS(obj,[],opts)Args:
obj [mdd]: Marginal Data Density object
opts [empty|struct]: options see help for mdd.global_options
- Returns:
:
log_mdd [numeric]: log marginal data density
See also
mdd.laplace, mdd.mhm, mdd.ris, mdd.cj, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.swz, mdd.global_options
laplace
laplace Computes the log marginal data density
log_mdd=laplace(obj)Args:
obj [mdd]: Marginal Data Density object
- Returns:
:
log_mdd [numeric]: log marginal data density
See also
mdd.mhm, mdd.is, mdd.ris, mdd.cj, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.swz
laplace_mcmc
laplace_mcmc Computes the log marginal data density using the laplace approximation and a covariance matrix computed from the draws of posterior sampling
log_mdd=laplace_mcmc(obj)Args:
obj [mdd]: Marginal Data Density object
- Returns:
:
log_mdd [numeric]: log marginal data density
See also
mdd.laplace, mdd.mhm, mdd.is, mdd.ris, mdd.cj, mdd.mueller, mdd.bridge, mdd.swz
laplace_mdd
Computes the log marginal data density using the laplace approximation
log_mdd=laplace_mdd(log_post,Hinv)Args:
log_post [numeric]: log of posterior kernel evaluated at the mode
Hinv [matrix]: inverse Hessian (negative of the second derivatives of the log posterior kernel)
- Returns:
:
log_mdd [numeric]: log marginal data density
mdd
mdd : Constructor for marginal data density objects
Syntax:
obj=mdd(theta_draws,log_post_kern,lb,ub) obj=mdd(theta_draws,log_post_kern,lb,ub,subset) obj=mdd(theta_draws,log_post_kern,lb,ub,subset,H) obj=mdd(theta_draws,log_post_kern,lb,ub,subset,H,maximization)Inputs
theta_draws [char|struct]: sampling drawss => In case of a char, this is the location of the folder containing the draws organized as described below => In case of a structure, the fields are “f” and “x”. Each parameter vector is defined as a structure, which means that theta_draws is a vector of structures. “x” is the parameter vector and “f” is the NEGATIVE of the log posterior kernel evaluated at “x”. In case “f” is instead the log posterior kernel itself, option maximization below has to be set to “true”.
lb [empty|vector]: lower bound of the search space. Replaced with the smallest value of each parameter in theta_draws if empty.
ub [empty|vector]: upper bound of the search space. Replaced with the largest value of each parameter in theta_draws if empty.
The bounds are the support of the posterior: a new draw outside them (is, mueller, bridge, cj, swz) has a zero posterior, and the posterior kernel is not evaluated there. Bounds taken from the draws leave out the posterior mass beyond the extremes of the draws (up to about 2*d/M for d parameters and M independent draws, more for correlated draws), and the log mdd comes out lower by about that much. Give the bounds of the prior to avoid it.
subset (cell array|{empty}): When not empty, subset is a 1 x 2 cell array in which the first cell contains a vector selecting the columns to retain in each chain and the second column contains the chains retained. Any or both of those cell array containts can be empty. Whenever an entry is empty, all the information available is selected. E.g. subsetting with dropping and trimming mysubs={a:b:c,[1,3,5]}. In this example, the first element selected is the one in position “a” and thereafter every “b” element is selected until we reach element in position “c”. At the same time, we select markov chains 1,3 and 5.
H [empty|matrix]: Hessian matrix for the parameters Necessary only for the laplace algorithm. If left empty, finite differences are used. It is the Hessian of log_post_kern at the mode: negative definite when maximization is true (the kernel is the log posterior), positive definite otherwise (minus the log posterior). A Hessian that is not definite in the sense expected is refused (rise:mdd:hessianNotDefinite).
maximization [{false}|true|empty]: Informs the procedure about whether we have a maximization or a minimization problem.
See also
mdd.laplace, mdd.mhm, mdd.is, mdd.ris, mdd.cj, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.swz
mhm
mhm Computes the log marginal data density using the “modified harmonic mean” approximation by [Geweke, 1999].
log_mdd=mhm(obj)Args:
obj [mdd]: Marginal Data Density object
mhm_tau [{(.1:.1:.9)}|vector|scalar|empty]: truncation probabilities
opts [empty|struct]: options see help for mdd.global_options
Returns:
log_mdd [numeric]: log marginal data density
See also
mdd.laplace, mdd.is, mdd.ris, mdd.cj, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.swz, mdd.global_options
mueller
MUELLER Computes the log marginal data density using the Ulrich Mueller’s approximation
log_mdd=MUELLER(obj) log_mdd=MUELLER(obj,[],opts)Args:
obj [mdd]: Marginal Data Density object
opts [empty|struct]: options see help for mdd.global_options
Returns:
log_mdd [numeric]: log marginal data density
See also
mdd.laplace, mdd.mhm, mdd.is, mdd.ris, mdd.cj, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.swz, mdd.global_options
normal_weighting
- mdd.normal_weighting is a function.
[loglik, v_iF_v, lik] = mdd.normal_weighting(v, det_Sigma, Sigma_i)
ris
RIS Computes the log marginal data density using the “Reciprocal Importance Sampling” approximation as in [Frühwirth-Schnatter, 2006]
log_mdd=RIS(obj) log_mdd=RIS(obj,[],opts)Args:
obj [mdd]: Marginal Data Density object
opts [empty|struct]: options see help for mdd.global_options
Returns:
log_mdd [numeric]: log marginal data density
See also
mdd.laplace, mdd.mhm, mdd.is, mdd.cj, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.swz, mdd.global_options
swz
SWZ Computes the log marginal data density using the [Sims et al., 2008] approximation
log_mdd=SWZ(obj) log_mdd=SWZ(obj,swz_pvalue) log_mdd=SWZ(obj,swz_pvalue,opts)Args:
obj [mdd]: Marginal Data Density object
swz_pvalue [{90}|empty|scalar]: scalar for the computation of the lower bound. Must be greater than 0 and less than 100
opts [empty|struct]: options see help for mdd.global_options
- Returns:
:
log_mdd [numeric]: log marginal data density
extras [struct]: lower bound and corresponding quantile
See also
mdd.laplace, mdd.mhm, mdd.is, mdd.ris, mdd.cj, mdd.mueller, mdd.bridge, mdd.laplace_mcmc, mdd.global_options