7.5.1. The properties
proxies
structure of proxies
endogenous
list of endogenous variables
Help for proxy_svar/endogenous is inherited from superclass abstvar
exogenous
list of exogenous variables
Help for proxy_svar/exogenous is inherited from superclass abstvar
parameters
list of parameters including var and non-var parameters
Help for proxy_svar/parameters is inherited from superclass abstvar
nonvar_parameters
list of non-var parameters e.g. auxiliary params, transition probabilities, etc.
Help for proxy_svar/nonvar_parameters is inherited from superclass abstvar
constant
boolean to specify whether the model has a constant term or not
Help for proxy_svar/constant is inherited from superclass abstvar
debug
for debugging purposes
Help for proxy_svar/debug is inherited from superclass abstvar
markov_chains
structure of markov chains
Help for proxy_svar/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 proxy_svar/is_time_varying_trans_prob is inherited from superclass abstvar
is_switching
boolean specifying whether the model is switching or not
Help for proxy_svar/is_switching is inherited from superclass abstvar
nlags
number of lags in the VAR
Help for proxy_svar/nlags is inherited from superclass abstvar
nx
number of exogenous variables including the constant term
Help for proxy_svar/nx is inherited from superclass abstvar
nvars
number of endogenous variables
Help for proxy_svar/nvars is inherited from superclass abstvar
nparams
number of parameters
Help for proxy_svar/nparams is inherited from superclass abstvar
nregs
number of regimes
Help for proxy_svar/nregs is inherited from superclass abstvar
7.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
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 proxy_svar/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 proxy_svar/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 proxy_svar/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
Parse identification
Help for proxy_svar/identification is inherited from superclass svar
irf
Compute Impulse-Response Functions for a SVAR model
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,girf_setup)Args:
self (svar object): var object
shock_names (empty|cellstr): List of shocks. Note that in each equation there is only one shock. If the list of shocks is not provided, RISE will create names varname_shock where “varname” is the name of an endogenous variable. The list of shocks will follow the order of declaration of the endogenous variables. If the number of shocks provided is less than the number of equations, those shocks will bevlisted first and RISE will create additional names to fill in the missing names.
irf_periods (int|{40}): number of periods to compute IRFs
params (empty|vector|matrix): parameter values of the model. If empty MLE/posterior-mode values are used. When not empty, the number of IRFs computed is equal to the number of columns of params.
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 (integer|{300}) : number of simulations for the integration.
Note
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
Help for proxy_svar/irf is inherited from superclass svar
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 proxy_svar/posterior_mode is inherited from superclass abstvar
print_solution
- proxy_svar/print_solution is a function.
print_solution(obj, varlist)
print_structural_form
INTERNAL FUNCTION
Help for proxy_svar/print_structural_form is inherited from superclass svar
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 proxy_svar.prior_template is inherited from superclass abstvar
proxy_svar
constructror for proxy_svar
mdl=proxy_svar(proxies,varlist)
mdl=proxy_svar(proxies,varlist,exog)
mdl=proxy_svar(proxies,varlist,exog,nlags)
mdl=proxy_svar(proxies,varlist,exog,nlags,constant)
mdl=proxy_svar(proxies,varlist,exog,nlags,constant,markov_chains)
Inputs:
proxies [empty|struct] : when not empty it should be an array of structures with fields :
“var” : the value should be the name of an endogenous variable
- “eqtn”# for the proxy equation. It should correspond
to declaration order of “var”
“coef” : name of the proxy coefficient
- “shock_eqtn”Equation whose shock is to be related to
the proxy equation
varlist [cellstr] : list of the endogenous variables. Should be ordered in a way that matches with the restrictions given in the proxies
exog [empty|cellstr] : list of the exogenous variables.
nlags [empty|{4}] : list of the exogenous variables.
constant [empty|false|{true}] : include a constant term
markov_chains [empty|struct] : array of structures describing markov processes
Outputs:
mdl [proxy_svar] : proxy_svar model object
Note
For the controlled parameters
The dynamic parameters of a svar model are denoted by “a”
The static parameters or coefficients on exogenous by “c”
for some parameter bd(row,col), e.g. a2(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
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 proxy_svar/pull_objective is inherited from superclass abstvar
residuals
Computes the residuals given the parameters
Help for proxy_svar/residuals is inherited from superclass abstvar
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 proxy_svar/set is inherited from superclass abstvar
solve
solve – Solves the VAR model.
This function is used to solve a VAR (Vector Autoregressive) model. It takes model parameters, data, and additional inputs, and returns the solution sol, a return code retcode, and a matrix M.
Syntax:
[sol, retcode, M] = solve(self, param, yt)
Inputs:
self [VARModel]: The VAR model object.
param [empty|struct|matrix]: Model parameters. If it is a matrix, then each column corresponds to a particular parameterization. If it is a structure, then it is the solution. If it is empty, the returned solution is computed used the parameter values stored inside the model object.
yt [matrix]: Data needed for endogenous probabilities. If not provided, the first observation from the model’s data is used.
Outputs:
sol [struct]: The solution to the VAR model.
retcode [int]: A return code indicating the success of the solution.
M [matrix]: Parameters for each regime
Example: - Solve the VAR model using provided parameters param and data yt:
`matlab [sol, retcode, M] = solve(varModel, param, yt); `See also
vartools.solve.
Help for proxy_svar/solve is inherited from superclass abstvar
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 proxy_svar/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.