.. index:: svar .. _svar: .. _svar_properties_methods: The properties =============== .. index:: svar.endogenous .. _svar.endogenous: endogenous ----------- list of endogenous variables Help for svar/endogenous is inherited from superclass abstvar .. index:: svar.exogenous .. _svar.exogenous: exogenous ---------- list of exogenous variables Help for svar/exogenous is inherited from superclass abstvar .. index:: svar.parameters .. _svar.parameters: parameters ----------- list of parameters including var and non-var parameters Help for svar/parameters is inherited from superclass abstvar .. index:: svar.nonvar_parameters .. _svar.nonvar_parameters: nonvar_parameters ------------------ list of non-var parameters e.g. auxiliary params, transition probabilities, etc. Help for svar/nonvar_parameters is inherited from superclass abstvar .. index:: svar.constant .. _svar.constant: constant --------- boolean to specify whether the model has a constant term or not Help for svar/constant is inherited from superclass abstvar .. index:: svar.debug .. _svar.debug: debug ------ for debugging purposes Help for svar/debug is inherited from superclass abstvar .. index:: svar.markov_chains .. _svar.markov_chains: markov_chains -------------- structure of markov chains Help for svar/markov_chains is inherited from superclass abstvar .. index:: svar.is_time_varying_trans_prob .. _svar.is_time_varying_trans_prob: is_time_varying_trans_prob --------------------------- boolean to specify whether we are in presence of a time-varying transition probability model Help for svar/is_time_varying_trans_prob is inherited from superclass abstvar .. index:: svar.is_switching .. _svar.is_switching: is_switching ------------- boolean specifying whether the model is switching or not Help for svar/is_switching is inherited from superclass abstvar .. index:: svar.nlags .. _svar.nlags: nlags ------ number of lags in the VAR Help for svar/nlags is inherited from superclass abstvar .. index:: svar.nx .. _svar.nx: nx --- number of exogenous variables including the constant term Help for svar/nx is inherited from superclass abstvar .. index:: svar.nvars .. _svar.nvars: nvars ------ number of endogenous variables Help for svar/nvars is inherited from superclass abstvar .. index:: svar.nparams .. _svar.nparams: nparams -------- number of parameters Help for svar/nparams is inherited from superclass abstvar .. index:: svar.nregs .. _svar.nregs: nregs ------ number of regimes Help for svar/nregs is inherited from superclass abstvar The methods ============ .. index:: svar.autocov .. _svar.autocov: 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 .. index:: svar.codify .. _svar.codify: 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 svar/codify is inherited from superclass abstvar .. index:: svar.estimate .. _svar.estimate: 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 :ref:`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 .. seealso:: - :ref:`posterior_mode ` - :ref:`identification ` - :ref:`prior template ` Help for svar/estimate is inherited from superclass abstvar .. index:: svar.filter .. _svar.filter: filter ------- filte: Compute the log likelihood of the VAR for the given parameters .. index:: filtering :: [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 ``estimate`` or ``identification`` . Help for svar/filter is inherited from superclass abstvar .. index:: svar.forecast .. _svar.forecast: 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); .. seealso:: vartools.forecast, vartools.conditional_forecast .. index:: svar.get .. _svar.get: 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. .. index:: svar.historical_decomposition .. _svar.historical_decomposition: 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). .. index:: svar.identification .. _svar.identification: identification --------------- Parse identification .. index:: svar.irf .. _svar.irf: 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 .. index:: svar.posterior_mode .. _svar.posterior_mode: 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 svar/posterior_mode is inherited from superclass abstvar .. index:: svar.print_solution .. _svar.print_solution: print_solution --------------- svar/print_solution is a function. print_solution(obj, varlist) .. index:: svar.print_structural_form .. _svar.print_structural_form: print_structural_form ---------------------- INTERNAL FUNCTION .. index:: svar.prior_template .. _svar.prior_template: prior_template --------------- prior_template : provides the default settings for priors in Bayesian VARs .. index:: prior :: 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 svar.prior_template is inherited from superclass abstvar .. index:: svar.pull_objective .. _svar.pull_objective: 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 svar/pull_objective is inherited from superclass abstvar .. index:: svar.residuals .. _svar.residuals: residuals ---------- Computes the residuals given the parameters Help for svar/residuals is inherited from superclass abstvar .. index:: svar.set .. _svar.set: 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 svar/set is inherited from superclass abstvar .. index:: svar.solve .. _svar.solve: 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); ``` .. seealso:: vartools.solve. Help for svar/solve is inherited from superclass abstvar .. index:: svar.svar .. _svar.svar: svar ----- svar : constructor for structural VAR models Syntax : :: mdl=svar(varlist) mdl=svar(varlist,exog) mdl=svar(varlist,exog,nlags) mdl=svar(varlist,exog,nlags,constant) mdl=svar(varlist,exog,nlags,constant,markov_chains) Args : - **varlist** (cellstr): List of endogenous variables - **exog** (empty\|cellstr): List of exogenous variables excluding the constant term - **nlags** (empty\|integer\|{4}): Number of lags in the VAR - **constant** (empty\|{true}\|false): boolean for including a constant term in the VAR or not - **markov_chains** (empty\|struct): structure 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** (svar): Constructed SVAR model .. 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 .. index:: svar.transform_var_into_dsge .. _svar.transform_var_into_dsge: 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 svar/transform_var_into_dsge is inherited from superclass abstvar .. index:: svar.variance_decomposition .. _svar.variance_decomposition: 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.