5.5.1. The properties
members
members of the panel
homogeneity
type of homogeneity of the panel (see list)
endogenous
list of endogenous variables
Help for prfvar/endogenous is inherited from superclass abstvar
exogenous
list of exogenous variables
Help for prfvar/exogenous is inherited from superclass abstvar
parameters
list of parameters including var and non-var parameters
Help for prfvar/parameters is inherited from superclass abstvar
nonvar_parameters
list of non-var parameters e.g. auxiliary params, transition probabilities, etc.
Help for prfvar/nonvar_parameters is inherited from superclass abstvar
constant
boolean to specify whether the model has a constant term or not
Help for prfvar/constant is inherited from superclass abstvar
debug
for debugging purposes
Help for prfvar/debug is inherited from superclass abstvar
markov_chains
structure of markov chains
Help for prfvar/markov_chains is inherited from superclass abstvar
is_time_varying_trans_prob
boolean to specify whether we are in presence of a time-varying transition probability model
Help for prfvar/is_time_varying_trans_prob is inherited from superclass abstvar
is_switching
boolean specifying whether the model is switching or not
Help for prfvar/is_switching is inherited from superclass abstvar
nlags
number of lags in the VAR
Help for prfvar/nlags is inherited from superclass abstvar
nx
number of exogenous variables including the constant term
Help for prfvar/nx is inherited from superclass abstvar
nvars
number of endogenous variables
Help for prfvar/nvars is inherited from superclass abstvar
nparams
number of parameters
Help for prfvar/nparams is inherited from superclass abstvar
nregs
number of regimes
Help for prfvar/nregs is inherited from superclass abstvar
5.5.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
bootstrap
Bootstrap the parameter values resampling \(\varepsilon_t\) terms from the data sample
RepsRun = bootstrap(rfvar, boot)
- Args:
rfvar (rfvar object): rfvar object boot (integer): number of bootstrap simulations (default: 1000)
- Returns:
:
RepsRun : bootstrapped values of the estimated parameters
dimension 1: parameter levels
dimension 2: different runs of bootstrap samples
- Example:
For example, one can compute variance of the estimate of the parameters by computing:
RepsRun = bootstrap(rfvar, 10000); var(RepsRun, [], 2)
Help for prfvar/bootstrap is inherited from superclass rfvar
codify
codify: transforms expressions such as a3(v1,v2,… into a3(2,3,… This can be used to facilitate the setting of priors on individual parameters of the VAR to estimate.
str=codify(self,str) str=codify(self,str,doCode)Args:
self (var object): var object
str (cellstr|string): string to transform. The string has one of the following forms:
a3(v1,v2,…: svar and proxy_svar parameters
b3(v1,v2,…: rfvar and prfvar parameters
c(v1,v2,… : deterministic terms
s(v1,v2,… : variance and covariance terms
doCode (true|{false}):
if false, return expression with parentheses e.g. a3(2,3)
if true, return expression with underscores e.g. a3_2_3
Returns:
str : transformed string
Example:
str=codify(psv,'a2(FFR,ygap)=0') str=codify(psv,'c(FFR,ygap,mpcoef,2)=0',true) str=codify(psv,'s(FFR,ygap,mpcoef,2)=0',true)Note
The function does not check whether the resulting parameter is actually a parameter in the model
The function also codifies expressions and not just individual parameters
Help for prfvar/codify is inherited from superclass abstvar
estimate
Estimates VAR parameters using frequentist/Bayesian interpretation
var = estimate(var); var = estimate(var, data); var = estimate(var, data, data_range); var = estimate(var, data, data_range, prior); var = estimate(var, data, data_range, prior, restrictions); var = estimate(var, data, data_range, prior, restrictions,optimizer); var = estimate(var, data, data_range, prior, restrictions,optimizer,is_fixed_regime);Args:
var (var object): var object
data (struct or ts obect): data for estimation
data_range (serial): (optional) date_range
prior (struct): priors for parameters
If no prior is given, maximum likehood estimators (frequentist) are set for parameters
With priors, posterior mode (Bayesian) values are set for parameters. There are three types of priors that can be applied individually or simultaneously. The prior structure can have fields :
var (struct) : (possibly modified) content of prior template
nonvar (struct): priors on individual parameters, which could be the VAR parameters, the transition probabilities or the parameters entering endogenous transition probabilities.
endogenous (function handle) : priors on the behavior of the system. e.g. a prior on some nonlinear function of the parameters.
restrictions : linear and nonlinear restrictions on parameters.
optimizer (char|function_handle|cell|{fmincon}) : optimization procedure. Used with optimization is required. e.g. markov switching. This can be the name of a standard matlab optimizer or RISE optimization routine or a user-defined optimization procedure available of the matlab search path. If the optimzer is provided as a cell, then the first element of the cell is the name of the optimizer or its handle and the remaining entries in the cell are options to the user-defined optimization routine. A user-defined optimization function must have the following syntax
[xfinal,ffinal,exitflag,H]=optimizer(fh,x0,lb,ub,options);That is, it accepts as inputs:
fh: the function to optimize
x0: a vector column of initial values of the parameters
lb: a vector column of lower bounds
ub: a vector column of upper bounds
options: a structure of options whose fields will be similar to matlab’s optimset
That is, it provides as outputs:
xfinal: the vector of final values
ffinal: the value of fh at xfinal
exitflag: a flag similar to the ones provided by matlab’s optimization functions.
H: an estimate of the Hessian
is_fixed_regime : (true|{false}): if true, the regimes are known in advance. In that case the data should contain time series for a variable called “hist_regimes”
Returns:
var (var object): var object with parameters estimated based on data
See also
Help for prfvar/estimate is inherited from superclass abstvar
filter
filte: Compute the log likelihood of the VAR for the given parameters
[LogLik,Incr,retcode,filtering] = filter(self); [LogLik,Incr,retcode,filtering] = filter(self, param);Args:
self (var object): var object
param (cell of struct): (optional) parameter values
Returns:
LogLik : log likelihood values of the VAR
Incr : period-by-period contributions to the likelihood
retcode : flag, 0 if no problem
filtering : structure containing filtration
Note:
Almost everything is automated in RISE, so see
estimateoridentification.
Help for prfvar/filter is inherited from superclass abstvar
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 Access/Query time series property values.
VALUE = get(TS,’PropertyName’) returns the value of the specified property of the time series object. An equivalent syntax is
VALUE = TS.PropertyName
get(TS) displays all properties of TS and their values.
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).
identification
Parses panel VAR identifying restrictions into RISE interpretable identification function
- Note:
This function is a part of a general workflow. See XXXXXXXXXX to check the workflow.
Rfunc = identification(var, restr, shock_names, varargin);Args:
var (rfvar object): rfvar object
restr : restrictions can take two forms
‘choleski’: choleski identification. Supply the ordering as a cell array as varargin{1}
cellstr: n x 2 cell array, with n the number of restrictions. A typical restriction takes the form:
‘vbl@shk’,’sign’
‘vbl{lags}@shk’,’sign’
where sign = +|- where shk is the name of the shock where vbl is the name of the endogenous variable affected by shock lags with defaut 0 is the list of lags at which the shock affects the variable with a ‘sign’ sign. lags is any valid expression that matlab can evaluate such as 0, 0:3, [1,4,5], [1,inf,2,5] or more generally a:b, [a:b,c,d], etc.
shock_names (cellstr): cell of structural shock names
- Returns:
:
Rfunc (function handle): a function that takes parameters and then returns structural shock matrix. This function function is not intended to be used used on its own, and supposed to be used as an argument in different functions.
See also
autocov
forecast
historical_decomposition
irf
variance_decomposition
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.
posterior_mode
Return the posterior mode from the BVAR estimation
dd = posterior_mode(self)
- Args:
self (var object): var object
- Returns:
:
dd (struct): posterior mode of the parameters
Help for prfvar/posterior_mode is inherited from superclass abstvar
prfvar
Constructor for rfvar object
mdl = prfvar(panel,endog); mdl = prfvar(panel,endog, exog); mdl = prfvar(panel,endog, exog, nlags); mdl = prfvar(panel,endog, exog, nlags, const); mdl = prfvar(panel,endog, exog, nlags, const, markov_chains);Args:
panel (struct): [optional] a struct of panel information including:
members (cellstring): cell of country names
homogeneity (string): assumptions made on the panel dimension. Available homogeneities are:
‘pooled’: all countries are assumed to have the same coefficients
‘meanGroup’: average across groups
‘independent’: nothing in common
‘static’: deterministic coefficients common
‘dynamic’: lag coefficients common
endog (cellstring): cell of endogenous variable names
exog (cellstring): cell of exogenous variable names (default: [])
nlags (integer): number of VAR lags to include (default: 4)
const (bool): whether to include constants (default: true)
markov_chains (struct): [optional] Struct containing the following fields:
‘name’: name of the markov process
‘number_of_states’: number of states
‘controlled_parameters’: list of controlled parameters
‘endogenous_probabilities’: definitions of the endogenous probabilities
‘probability_parameters’: parameters entering the time-varying transition probabilities
Returns:
mdl : constructed prfvar object
Note
For the controlled parameters
The dynamic parameters of a rfvar model are denoted by “b”
The static parameters or coefficients on exogenous by “c”
for some parameter bd(row,col), e.g. b2(2,3)
d (empty|integer) : when empty, all lags are swept through
row (integer|string) : denotes the row, which can be an integer of a string corresponding to the name of an endogenous variable
col (integer|string) : denotes the row, which can be an integer of a string corresponding to the name of an endogenous variable
print_solution
- prfvar/print_solution is a function.
print_solution(obj, varlist)
prior_template
prior_template : provides the default settings for priors in Bayesian VARs
prior=prior_template()Args : None
Returns:
prior (struct) : structure with fields :
L1 (numeric|{0.1}) : Overall tightness
L2 (numeric|{0.5}) : Cross-variable specific variance parameter
L3 (numeric|{1}) : Speed at which lags greater than 1 converge to zero
L4 (numeric|{100}) : tightness on deterministic/exogenous terms
L5 (numeric|{3}) : covariance dummies(omega)
L6 (numeric|{5}) : co-persistence (lambda)
L7 (numeric|{2}) : Own-persistence (mu)
coefprior (numeric scalar|vector|{1}): mean of coefficients on own first lag. This allows you to set the prior mean to whatever value you believe in. e.g. one might believe that, say, the growth rate is stationary and so is less persistent than say, the interest rate or inflation.
type (string): type of prior. one of the following:
‘minnesota’ : Minnesota prior
‘normal-wishart’ or ‘nw’ : Normal Wishart prior
‘indep-normal-wishart’ or ‘inw’ : Independent normal wishart prior
‘jeffrey’ : Jeffrey prior
‘sims-zha’ or ‘sz’: Sims and Zha prior
normal_wishart_eta (numeric|{0.01}) : Prior variance for the normal-wishart prior
independent_normal_wishart_eta (numeric|{0.01}) : prior variance for the independent-normal-wishart prior
Warning
At the moment only the Sims-Zha and (possibly) the Jeffrey prior work. The other priors need some updating.
Help for prfvar.prior_template is inherited from superclass abstvar
pull_objective
Pulls the objective function to optimize
[ff,lb,ub]=pull_objective(self) [ff,lb,ub,x0]=pull_objective(self) [ff,lb,ub,x0,vcov]=pull_objective(self) [ff,lb,ub,x0,vcov,self]=pull_objective(self)Args:
self (svar | rfvar): initial model object
- 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.
self [rise|dsge|svar|rfvar]: updated model object
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 prfvar/pull_objective is inherited from superclass abstvar
residuals
Computes the residuals given the parameters
set
Sets options for the VAR XXXXXXXXXXX need to check
var_obj = set(var_obj,varargin);
- Args:
var_obj (var object): VAR object varargin: Options to set. Must come in pairs
‘data’: Data for the VAR. Can be either a struct or ts object
‘prior’: Prior to use if BVAR. Available priors are
minnesota
jeffrey
nw
normal-wishart
inw
sz
‘linear_restrictions’: Linear restrictions. For the format, see XXXXXXXXX
- Returns:
:
var_obj (var object): New VAR with the given inputs updated.
Help for prfvar/set is inherited from superclass abstvar
solve
INTERNAL FUNCTION: Solves for the consistent parameters for the VAR
structural_shocks
- prfvar/structural_shocks is a function.
[s, retcode] = structural_shocks(self, params, Rfunc, shock_names)
transform_var_into_dsge
transform_var_into_dsge : transforms a parameterized VAR into a DSGE model.
SYNTAX
m=transform_var_into_dsge(v)
m=transform_var_into_dsge(v,exogenousValues)
INPUTS
v [rfvar|svar|proxy_var|prfvar]: parameterized VAR object
exogenousValues [empty|struct]: structure containing the values for the exogenous variables. This is because the DSGE does not contain exogenous variables. Therefore the values of the exogenous variables has to be fixed.
OUTPUTS
m [rise]: parameterized DSGE model
NB : At the moment, the routine does not support regime switching models. The feature will be implemented if there is a demand for it.
Help for prfvar/transform_var_into_dsge is inherited from superclass abstvar
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.