3.3.1. The properties

nlags

bvar_dsge/nlags is a property.

constant

bvar_dsge/constant is a property.

endogenous

bvar_dsge/endogenous is a property.

options

bvar_dsge/options is a property.

shocks

bvar_dsge/shocks is a property.

parameters

information on parameters (names, number, types, etc.)

Help for bvar_dsge/parameters is inherited from superclass estimable

markov_chains

information on markov chains, regimes and related items

Help for bvar_dsge/markov_chains is inherited from superclass estimable

estimation

information on estimation: posterior maximization and simulation

Help for bvar_dsge/estimation is inherited from superclass estimable

3.3.2. The methods

autocov

Compute the autocovariances (and the auto-correlation) of endogenous variables given the parameter values

[C,R,retcode] = autocov(self);
[C,R,retcode] = autocov(self, params);
[C,R,retcode] = autocov(self, params, max_periods);
Args:

self (var object): var object params (cell of struct): struct containing var model related parameters (default: []) max_periods (integer): maximum number of period to calculate auto-covariance (default: 5)

Returns:

:

  • C [4-dimensional array]: auto-covariance where dimensions correspond to

    • 1,2: covariance

    • 3: time lags

    • 4: Number of parameters

  • R [4-dimensional array]: auto-correlation with same dimensions

bvar_dsge

bvar_dsge Construct an instance of the bvar_dsge class

obj = bvar_dsge(dsgemodel)

obj = bvar_dsge(dsgemodel,nlags)

obj = bvar_dsge(dsgemodel,nlags,const)

obj = bvar_dsge(dsgemodel,nlags,const,shock_list)

INPUTS

  • dsgemodel [dsge|rise|char|cell array]

    * dsge or rise : well understood * char : rise file name * cell array

    1. multiple rise files {‘file1’,’file2’,…,’filen’}

    2. one file and arguments {‘file1’,’arg1’,argval1,…,’argn’,argvaln}

    3. multiple rise files and arguments {{‘file1’,’file2’,…,’filen’},’arg1’,argval1,…,’argn’,argvaln}

  • nlags [numeric|{4}] : number of lags

  • const [false|{true}] : constant in the VAR

  • shock_list [empty|cell array] : list of selected shocks in the DSGE in case the DSGE model has more shocks than the number of observables.

OUTPUTS

  • obj [bvar_dsge]

TODO (if there is a demand for it)

  • add exogenous variables as in a normal VAR

  • Turn on the possibility of drawing from a Normal-inverse-Wishart prior when running impulse responses. At the moment the feature is turned of because for every parameter draw, only one single IRF is computed and not a distribution.

draw_parameter

Random parameter draws for RISE model objects.

[draw,obj] = draw_parameter(obj,simulation_folder);

Args:

  • obj (rise | dsge | rfvar | svar): RISE model object

  • simulation_folder (char | struct):

    • char(1): simulation folder : the stored elements should be structures with fields:

      • x : parameter vectors

      • f : value of minus(log posterior kernel)

    • char(2): [‘mode’|’prior’]: draw from the prior distribution or from a multivariate normal distribution around the mode.

Returns:

  • draw [cell]: the first entry is the names of the estimated parameters and the second is a vector of drawn parameters. The whole cell can be pushed in to a model as obj=set(obj,’parameters’,draw).

  • obj [rise|dsge|rfvar|svar]: RISE model object in which the drawn parameter has been pushed.

Help for bvar_dsge/draw_parameter is inherited from superclass estimable

estimate

Estimate the parameters of a RISE model

obj=estimate(obj)
obj=estimate(obj,varargin)
[obj,filtration]=estimate(...)

Args:

  • obj (bvar_dsge): model object

  • varargin : additional optional inputs among which the most relevant for estimation. See ESTIMABLE/ESTIMATE

fisher

INTERNAL FUNCTION

Help for bvar_dsge/fisher is inherited from superclass estimable

forecast

FORECAST Generate forecasts for a model object.

Syntax:

[fkst, retcode] = forecast(self)

[fkst, retcode] = forecast(self, histdb)

[fkst, retcode] = forecast(self, histdb, date_start)

[fkst, retcode] = forecast(self, histdb, date_start, params)

[fkst, retcode] = forecast(self, histdb, date_start, params, nsteps)

[fkst, retcode] = forecast(self, histdb, date_start, params, nsteps, …

shock_uncertainty)

[fkst, retcode] = forecast(self, histdb, date_start, params, nsteps, …

shock_uncertainty, Rfunc)

[fkst, retcode] = forecast(self, histdb, date_start, params, nsteps, …

shock_uncertainty, Rfunc, conditions)

Inputs:
  • self: Model object (VAR|SVAR|BVAR-DSGE|Proxy-SVAR|Panel VAR).

  • histdb: (Database|empty) Database of historical data. If empty, the estimation data used in the model object is used.

  • date_start: (rise date|empty) Start date of the forecasts. If empty, the forecasts start right after the end of the sample given in histdb.

  • params: Matrix of parameter values to update the model object with for every forecast. If empty, the parameterized model is used.

  • nsteps: (numeric|{12}) Number of forecasting steps.

  • shock_uncertainty: Flag indicating whether to consider shock uncertainty.

  • Rfunc: (function handle|empty) Identification function for shocks. If empty, a cholesky identification is assumed.

  • conditions: Conditions for conditional forecasting (can be empty). The conditions can include endogenous variables, shocks, and “regime”.

Outputs:
  • fkst: Structure with forecasted variables.

  • retcode: Return code indicating if there was any issue during forecasting.

    0 indicates no issues.

Notes:
  • If no arguments are provided, default values are assumed for each parameter.

  • For conditional forecasting, specify conditions including endogenous variables, shocks, and “regime”.

Example:

% Simple unconditional forecast [fkst, retcode] = forecast(myModel, historicalData, rq(2024,1), params, 12);

See also

vartools.forecast, vartools.conditional_forecast

get

get - Query graphics object properties

This MATLAB function displays the properties and property values for the specified graphics object h in the Command Window.

Syntax

get(h) s = get(h) v = get(h,propertyNames) s = get(h,”default”) s = get(groot,”factory”) v = get(h,defaultTypeProperty) v = get(groot,factoryTypeProperty)

Input Arguments
h - Graphics objects

single object | vector of objects

propertyNames - Property names

string scalar | character vector | cell array

defaultTypeProperty - Default property name

string scalar | character vector

factoryTypeProperty - Factory property name

string scalar | character vector

Output Arguments
s - Property names and values

structure

v - Property values

any value | cell array

Examples

openExample(‘graphics/ListAllPropertyValuesForSpecificObjectExample’) openExample(‘graphics/QuerySpecificPropertyOfSpecificObjectExample’) openExample(‘graphics/GetSetOfPropertiesForSpecificObjectExample’) openExample(‘graphics/GetDefaultPropertyValueOnRootExample’) openExample(‘graphics/GetDefaultPropertyValueForObjectExample’) openExample(‘graphics/GetDefaultPropertyValuesOnRootExample’)

See also findobj, set, gcf, gca, gco

hessian

Computes the hessian of the model at a specific point

[obj,H,issue] = hessian(obj)

[obj,H,issue] = hessian(obj,x)

[obj,H,issue] = hessian(obj,x,varargin)

Args:

  • obj (rise | dsge | rfvar | svar): model object

  • x ([] | vector): vector at which one wants to compute the hessian

  • varargin: additional optional inputs among which the most relevant for estimation is:

    • hessian_type [{‘fd’}|’opg’]: The hessian is either computed by finite differences (fd) or by outer-product-gradient (opg)

Returns:

:

  • obj [rise|dsge|rfvar|svar]: model object containing the new hessian in case the model was previously estimated.

  • H [d x d matrix]: hessian matrix

  • issue [char|’’]: any issue encountered during the computation of the hessian

Help for bvar_dsge/hessian is inherited from superclass estimable

historical_decomposition

HISTORICAL_DECOMPOSITION Performs historical decomposition of shocks in a time series model.

This function computes the contributions of various shocks to the historical movements of the variables in a model, using the specified model parameters and shock identification function.

Inputs:

self      - The model object containing all necessary model structures and data.
params    - The parameters of the model used for the decomposition.
Rfunc     - A function handle to identify the shocks.
varargin  - Additional options, including the date range for analysis.

Outputs:

hd        - The historical decomposition of each variable in the model, with details on the
            contributions of each shock and other components.
retcode   - Return code that indicates the status of the computation (0 = success).

irf

Compute impulse response function from the given parameter values

myirfs = irf(self)

myirfs = irf(self, shock_names)

myirfs = irf(self, shock_names, irf_periods)

myirfs = irf(self, shock_names, irf_periods, params)

myirfs = irf(self, shock_names, irf_periods, params, Rfunc)

myirfs = irf(self, shock_names, irf_periods, params, Rfunc,girf_setup)

Args:

  • self (var object): var object

  • shock_names (cellstr): shocks for which to compute IRFs (has to be consistent with the identification scheme identification)

  • irf_periods (int): number of periods to compute IRFs (default: 40)

  • params (vector): parameter values of the model. If empty MLE/posterior-mode values are used.

  • Rfunc (function handle): identification function. This is an output of identification. (default: choleski identification)

  • girf_setup (struct|{empty}): structure containing information relevant for the computation of generalized impulse response functions. If empty, simple regime-specific impulse responses are computed, else girfs are computed. In that case the relevant information to provide in girf_setup is:

    • nsims : (default=300) number of simulations for the integration. Note that even setting girf_setup=struct() will trigger the computation of girfs. But in that case only the default options will apply.

Returns:

  • myirfs : (struct) structure containing the IRFs

Note

Only successful IRFs are returned. If the structure does not return some IRFs make sure that IRFs properly identified.

load_parameters

load_parameters loads the parameters. This allows the user to quickly load the parameters from a file, which may be the output of estimation, and get going with irfs, simulations, etc.

model=load_parameters(model,the_mode_file)

Args:

  • model (estimable object): model object

  • the_mode_file (m-file): file containing the parameters and their values

Returns:

  • model (estimable object): reparameterized model object

Help for bvar_dsge/load_parameters is inherited from superclass estimable

log_posterior_kernel

Computes the log posterior of the dsge model

[log_post,log_lik,log_prior,Incr,retcode,obj]=log_posterior_kernel(obj, param)

Args:

  • obj (estimable object): model object

  • param (column vector): parameter values

Returns:

  • log_post (double): log posterior

  • log_lik (double): log likelihood

  • log_prior (double): log prior

  • Incr (double):

  • retcode : return code

  • obj (estimable object): model passed through

Note

In effort to make RISE modular, this function is available so that one can use a different sampler if needed, but most likely, one should just use available stock samplers.

Help for bvar_dsge/log_posterior_kernel is inherited from superclass estimable

log_prior_density

Computes the probability density function of the prior corresponding to the parameter values

[lnprior, retcode] = log_prior_density(model)
[lnprior, retcode] = log_prior_density(model, param)
[lnprior, retcode] = log_prior_density(model, param,filtration)

Args:

  • model (estimable object): model object

  • param (column vector): parameter values

  • filtration (empty|struct): results from model filtration that can potentially be used for endogenizing priors.

Returns:

  • lnprior (double): log of prior density function

  • retcode: return code

Note

In effort to make RISE modular, this function is available so that one can use a different sampler if needed, but most likely, one should just use available stock samplers.

Help for bvar_dsge/log_prior_density is inherited from superclass estimable

mode_curvature

Checks the curvature at the posterior mode

db = mode_curvature(obj)

db = mode_curvature(obj,varlist)

db = mode_curvature(obj,varlist,N)

db = mode_curvature(obj,varlist,N,type)

Args:

  • obj (rise | dsge | rfvar | svar): model object

  • varlist (char | cellstr | empty): list of parameters for which we want to check the curvature

  • N ({20} | integer): Number of grid points

  • type ({‘max’} | ‘min’ | ‘range’): normalization of the log-posterior and the log-likelihood.

  • dbin (struct|empty): structure containing the information to plot the curvature. Each field is the name of a particular parameter. This is to avoid a costly recomputation of db

Returns:

  • db [struct|cell array|vector]: structure containing the information to plot the curvature. Each field is the name of a particular parameter. Alternatively, when dbin is not empty, db is a handle to the plots.

Note:

  • when no output is requested, plots are made but not saved.

  • one way to plot the curvatures from the output is to use the function utils.plot.curvature

See also

  • utils.plot.curvature

Help for bvar_dsge/mode_curvature is inherited from superclass estimable

posterior_sample

Computes a sample of any quantity of interest using parameter draws from a population e.g. a posterior simulation

[result]=posterior_sample(m,pop,dowhat)

[result]=posterior_sample(m,pop,dowhat,howmany)

[result]=posterior_sample(m,pop,dowhat,howmany,ouf)

[result]=posterior_sample(m,pop,dowhat,howmany,ouf,varargin)

[result,is_failed,time_it_took]=posterior_sample(...)

Args:

  • m [rise|dsge|svar|rfvar|valid rise object]: model object

  • pop [m x n struct]: parameter draws, with “m” the number of chains and “n” the number of draws in each chain. Each element of “pop” is a structure with fields “f” (not used), the value of the posterior and “x” the parameter vector

  • dowhat [fhandle]: function (handle) to apply to each parameterized model object. e.g. dowhat=@irf, dowhat=@simulate, dowhat=@forecast, etc. “dowhat” need not be a method of “m”: it represents the quantity of interest.

  • howmany [integer|{m x n}]: number of draws to use in the calculation

  • ouf [fhandle|{[]}]: output update function. Function that updates the output before storing it. e.g. if dowhat=@filter, one may be interested in the filters only and in that case ouf=@(x)x.filtering.

  • varargin [pairwise args]: valid pairwise arguments for the model object

Returns:

  • result [1 x howmany cell]: container of the various applications of the “dowhat” handle

  • time_it_took [numeric]: number of seconds needed to run all the simulations.

See also

draw_parameter

Note

  • the function will exploit parallel computation if there are workers idle.

  • Because the solving of the model is sometimes iterative, a change of solver or of the settings of the solver can result in the model not being solved or more generally simulations failures. The algorithm will loop until the requested number of simulations is obtained. But it will not point to the parameter vectors that fail.

Help for bvar_dsge/posterior_sample is inherited from superclass estimable

pull_objective

Pulls the objective function to optimize

[ff,lb,ub]=pull_objective(obj)
[ff,lb,ub]=pull_objective(obj,varargin)
[ff,lb,ub,x0]=pull_objective(obj,varargin)
[ff,lb,ub,x0,vcov]=pull_objective(obj,varargin)
[ff,lb,ub,x0,vcov,obj]=pull_objective(obj,varargin)
[ff,lb,ub,x0,vcov,obj,constraints]=pull_objective(obj,varargin)

Args:

  • obj (rise | dsge | svar | rfvar): initial model object

  • varargin (pairwise addional inputs): usual RISE arguments

Returns:

  • ff [function handle]: for computing “minus log posterior kernel”

  • lb [d x 1 vector]: lower bound of the parameters to optimize

  • ub [d x 1 vector]: upper bound of the parameters to optimize

  • x0 [d x 1 vector]: posterior mode if available

  • vcov [d x d matrix]: covariance matrix at the posterior mode if available.

  • obj [rise|dsge|svar|rfvar]: updated model object

  • constraints [rise|dsge|svar|rfvar]: Matrix where each row is [index1, index2], corresponding to a constraint that index1 <= index2 after normalization.

Note:

  • The function can be used for :

    • optimization,

    • gradient computation,

    • hessian computation,

    • posterior simulation

  • The updated object should be used for doing various exercises (irfs, simulations, etc.) if the posterior mode is not computed.

  • Using this function is potentially costly. One could alternatively simply use log_posterior_kernel. However, if there are restrictions, they will not be enforced. Nevertheless it is an interesting proposition that should be investigated further.

Help for bvar_dsge/pull_objective is inherited from superclass estimable

residuals

Computes the residuals given the parameters

set

METHOD1 Summary of this method goes here

Detailed explanation goes here

solve

INTERNAL FUNCTION: intermediary file for computing key elements for dsge-var

[sol,retcode,self] = solve(self)
[sol,retcode,self] = solve(self,params)
[sol,retcode,self] = solve(self,params,whichVar)

Args:

  • self (bvar_dsge): model object

  • params

  • whichVar [‘var’|’var_approx’|{‘var_dsge’}]: choose which VAR you want to solve. Where :

    • var : is the classical VAR without priors

    • var_approx : is the VAR approximation of the DSGE

    • var_dsge : is the Bayesian VAR with the (VAR approximation of the) DSGE as prior

Returns:

  • self [bvar_dsge]: model object

variance_decomposition

Compute the variance decompsition of the VAR

[vd,retcode] = variance_decomposition(self)

[vd,retcode] = variance_decomposition(self,params)

[vd,retcode] = variance_decomposition(self,params,Rfunc)

[vd,retcode] = variance_decomposition(self,params,Rfunc,nperiods)

Args:

  • self (var object):

  • params :(optional) parameter values

  • Rfunc (function handle): (optional) transform parameters into dynamics

  • nperiods :(optional) periods for decomposition

Returns:

  • vd (struct): a struct containing the variance decomposition:

    • infinity (struct):

    • conditional (struct):

  • retcode (integer): This passes through the retcode given by Rfunc. Currently (2018/07/19), this output always returns 0.