This page documents the Dynare interface to the Markov Switching VAR code from Sims, Waggoner and Zha (SWZ).

# Existing interface

Two commands are already available from MOD files (in Dynare unstable version):

for structural BVARs without Markov Switching:

`sbvar`for structural BVARs with Markov Switching:

`ms_sbvar`

These two commands accept the options listed on the MarkovSwitchingOptions page: fourth column of the table gives the name of the option from Dynare standpoint, and last column is the default value.

# Proposal for extending the interface

## SVAR identification

SVAR identification scheme is described in

`svar_identification`block:svar_identification; ... ... end;

- Well-know schemes are identified by simple keywords. Currently:
svar_identification; upper_cholesky; end;

orsvar_identification; lower_cholesky; end;

More sophisticated schemes are described by listing exclusion restrictions on

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:32.894526 2021] [wsgi:error] [pid 2976:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

orlatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:32.944254 2021] [wsgi:error] [pid 2977:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

:svar_identification; exclusion lag 0; equation 1, y, pi; equation 2, pi, r; exclusion lag 1; equation 1, y, pi; equation 2, pi, r; end;

This generatesoptions_.ms.Qi options_.ms.Ri

See detail of the implementation in SvarExclusionInterface

- The constant can be excluded in every equation:
svar_identification; exclusion constants; exclusion lag 0; equation 1, y, pi; equation 2, pi, r; ... end;

orsvar_identification; exclusion constants; upper_cholesky; end;

Note that

`options_.ms.Ri`doesn't reflect exclusion of constants. This is added later on the fly by`./matlab/ms-sbvar/identification/exclusion.m`when computing`Vi` - Syntax for linear restrictions:
- Example

svar_identifications; ... restriction equation 1, coeff(y,-1)-coeff(pie,-1)=0; restriction equation 2, coeff(y,-2) = 0; ... end;

`coeff(y,-1)`returns a pair with`symbol_id`for`y`and`lead_lag=-1`the constraint is in the form

`EXPRESSION = EXPRESSION`, the preprocessor must form an homogeneous equation.the homogeneous equation must be derived with respect to the

`coeff()`terms.`options_.ms.Qi`and`options_.ms.Ri`are filed with these partial derivatives.- it is possible to use this richer syntax to enter the simpler exclusion restrictions above.

`svar_identification`MUST BE indicated BEFORE`sbvar`or`ms_sbvar`statement!

The SVAR model is written as:

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.004019 2021] [wsgi:error] [pid 2978:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

where

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.055613 2021] [wsgi:error] [pid 2979:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceis an

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.110119 2021] [wsgi:error] [pid 2980:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacevector of endogenous variables,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.161715 2021] [wsgi:error] [pid 2981:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceis a vector of all lagged variables plus the constant term, the state

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.213188 2021] [wsgi:error] [pid 2982:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacefollows a Markov process,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.268645 2021] [wsgi:error] [pid 2983:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceis a diagonal matrix in which the diagonal elements represent the state-dependent shock variances, and

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.319911 2021] [wsgi:error] [pid 2984:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacehas a Gaussian distribution with mean 0 and variance matrix

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.372027 2021] [wsgi:error] [pid 2985:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface. The order of

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.423655 2021] [wsgi:error] [pid 2986:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacefollows this convention. The ordering of variables in each equation has the following convention. The

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.460031 2021] [wsgi:error] [pid 2987:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacevariables at the first lag are order first, followed by the

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.513625 2021] [wsgi:error] [pid 2988:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacevariables at the second lag, and so on. The last variable is the constant term.

## Restrictions on SVAR Markov-switching processes

SWZ introduce a restriction on the lagged coefficients in the SVAR. It can be called by `svar_restriction(SWZ)`. The restriction is essential to overparameterization by preventing an *excessive* number of parameters from changing from one state to another. The restrictions take the following form:

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.573186 2021] [wsgi:error] [pid 2989:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

where

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.627689 2021] [wsgi:error] [pid 2990:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacestands for the

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.676351 2021] [wsgi:error] [pid 2991:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacevariable,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.725391 2021] [wsgi:error] [pid 2992:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacefor the

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.777405 2021] [wsgi:error] [pid 2993:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceequation, and

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.833270 2021] [wsgi:error] [pid 2994:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacefor the

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.881517 2021] [wsgi:error] [pid 2995:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacelag. This expression indicates that the coefficients at the first lag may change with state but the coefficients at other lags in each state are proportional those at the first lag in that state.

## Prior specification on SVAR coefficients

The Sims and Zha (1998) prior applies to

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.935393 2021] [wsgi:error] [pid 2996:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacefor all

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:33.985223 2021] [wsgi:error] [pid 2997:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceand

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.039523 2021] [wsgi:error] [pid 2998:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface(in the original article by Sims and Zha (1998), the hyperparameter

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.097394 2021] [wsgi:error] [pid 2999:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceis always set to 1). There are six hyperparameters controlling the tightness of this prior:

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.147005 2021] [wsgi:error] [pid 3000:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

controls overall tightness of the random walk prior (same aslatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.191117 2021] [wsgi:error] [pid 3001:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

in Sims and Zha (1998)).latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.241659 2021] [wsgi:error] [pid 3002:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

controls relative tightness of the random walk prior on the lagged coefficients (same aslatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.293293 2021] [wsgi:error] [pid 3003:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

in Sims and Zha (1998)).latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.352016 2021] [wsgi:error] [pid 3004:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

controls relative tightness of the random walk prior on the constant term (same aslatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.406546 2021] [wsgi:error] [pid 3005:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

in Sims and Zha (1998)).latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.463440 2021] [wsgi:error] [pid 3006:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

controls tightness of the prior that dampens the erratic sampling effects on lag coefficients (lag decay) (same aslatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.513141 2021] [wsgi:error] [pid 3007:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

in Sims and Zha (1998)).latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.566795 2021] [wsgi:error] [pid 3008:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

controls weight on the sum of coefficients in each equation throughlatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.618651 2021] [wsgi:error] [pid 3009:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

dummy observations excluding the constant term. This component of the prior expresses belief about unit roots (same aslatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.662281 2021] [wsgi:error] [pid 3010:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

in Sims and Zha (1998)).latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.717104 2021] [wsgi:error] [pid 3011:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

controls weight on a single dummy initial observation including the constant term. This component of the prior expresses belief in cointegration relationships (up tolatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.768053 2021] [wsgi:error] [pid 3012:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

) and stationarity (same aslatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.819630 2021] [wsgi:error] [pid 3013:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

in Sims and Zha (1998)).

Note that while smaller values of

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.871187 2021] [wsgi:error] [pid 3014:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacefor

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.924630 2021] [wsgi:error] [pid 3015:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacemeans a tighter random walk prior, larger values of

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:34.976602 2021] [wsgi:error] [pid 3016:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacefor

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.030951 2021] [wsgi:error] [pid 3017:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacemeans a tighter prior on unit roots and cointegration. We provide the following benchmark values of these hyperparameters, although one should vary the values for sensitivity check. For quarterly data, Sims and Zha (1998) suggest

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.088791 2021] [wsgi:error] [pid 3018:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.143202 2021] [wsgi:error] [pid 3019:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.195832 2021] [wsgi:error] [pid 3020:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.250343 2021] [wsgi:error] [pid 3021:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.303142 2021] [wsgi:error] [pid 3022:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface, and

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.346813 2021] [wsgi:error] [pid 3023:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface. For monthly data, Sims and Zha (2006) suggest

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.399320 2021] [wsgi:error] [pid 3024:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.458075 2021] [wsgi:error] [pid 3025:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.513040 2021] [wsgi:error] [pid 3026:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.571195 2021] [wsgi:error] [pid 3027:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface,

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.627680 2021] [wsgi:error] [pid 3028:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface, and

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.682488 2021] [wsgi:error] [pid 3029:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface.

The prior on

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.734505 2021] [wsgi:error] [pid 3030:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfacefor each

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.787180 2021] [wsgi:error] [pid 3031:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceand

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.840913 2021] [wsgi:error] [pid 3032:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceis a normal distribution with mean 0 and standard deviation 50. This prior is diffuse enough to allow for the possibility that VAR coefficients can have extremely large values for some states.

The prior on each element of the diagonal of

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.890804 2021] [wsgi:error] [pid 3033:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface(denoted as Zeta in our output file) is a gamma distribution, represented by Gamma(

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:35.944056 2021] [wsgi:error] [pid 3034:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface) with

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:36.001071 2021] [wsgi:error] [pid 3035:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterfaceand

latex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:36.054864 2021] [wsgi:error] [pid 3036:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface.

## Prior specification on Markov Switching processes

Original Markov Switching Bvar syntax. Priors on Markov Switching processes are specified through average duration of each regime

`markov_switching(chain=i, regime=j, duration=d)`specifies that regimelatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:36.111953 2021] [wsgi:error] [pid 3037:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

in chainlatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:36.167518 2021] [wsgi:error] [pid 3038:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

lasts on averagelatex error! exitcode was 2 (signal 0), transscript follows: [Wed Sep 08 09:35:36.226471 2021] [wsgi:error] [pid 3039:tid 139902268151552] [client 192.168.1.1:52028] failed to exec() latex, referer: https://www.dynare.org/DynareWiki/MarkovSwitchingInterface

periods. Alternatively, if all the regimes have the same average duration, it is possible to simply declare the number of regimes in the chain with option`number_of_regimes`. A duration equal to infinity means an absorbing state. Example:markov_switching(chain=1, regime=1, duration=3); markov_switching(chain=1, regime=2, duration=0.5); markov_switching(chain=2, regime=1, duration=1); markov_switching(chain=2, regime=2, duration=4.5); markov_switching(chain=2, regime=3, duration=Inf); markov_switching(chain=3, number_of_regimes=2, duration=2.5);

Matlab implementation:options_.ms.ms_chain(1).regime(1).duration = 3; options_.ms.ms_chain(1).regime(2).duration = 0.5; options_.ms.ms_chain(2).regime(1).duration = 1; options_.ms.ms_chain(2).regime(2).duration = 4.5; options_.ms.ms_chain(2).regime(3).duration = Inf; options_.ms.ms_chain(3).regime(1).duration = 2.5; options_.ms_ms_chain(3).regime(2).duration = 2.5;

For each chain, Matlab code will use this information to build the corresponding transition matrix.Please

**NOTE**the following:The change from

`state`to`regime`and`number_of_states`to`number_of_regimes`took place on 21/12/11.The removal of the

`regime`option took place on 21/12/11.The correct way to specify an absorbing state is through the

`restrictions`statement outlined below and not by passing`Inf`to the duration option. The ability to pass the`restrictions`argument was added on XX/XX/XX. The possibilty to pass`Inf`to the duration argument was removed on XX/XX/XX.

Markov Switching DSGE syntax is a superset of the new Markov Switching Bvar syntax. The Markov Switching Bvar syntax does

**NOT**contain the`parameter`and`number_of_lags`options but is otherwise the same as the Markov Switching DSGE syntax. Specifying a Markov Switching process for the DSGE code takes the following formmarkov_switching(chain=1, number_of_regimes=3, duration=2.5, parameter=[alpha, rho, phi], number_of_lags=2, restrictions=[[1,3,0],[3,1,0]]); markov_switching(chain=1, number_of_regimes=3, duration=[0.5, 2.5, 2.5], parameter=[alpha, rho, phi], number_of_lags=2, restrictions=[[1,3,0],[3,1,0]]);

The

`chain`option takes an integer value. Chains must be consecutive, positive integers, beginning at`1`. The`number_of_regimes`option specifies the total number of regimes in the markov chain. The`duration`, when passed a real number, specifies the average duration for all regimes in this chain. When passed a vector of size equal`number_of_regimes`, it specifies the average duration of the associated regime (`1:number_of_regimes`) in this chain. The`parameters`option shows which parameters are controlled by this markov chain. The`number_of_lags`option provides the number of lags that each parameter can take within each regime in this chain. The`restrictions`option provides restrictions on this chain's regime transition matrix. Its vector argument takes three inputs of the form:`[current_period_regime, next_period_regime, transition_probability]`(the first two entries are positive integers, and the third is a non-negative real in the set`[0,1]`). Needless to say, if restrictions are specified for every transition for a regime, the preprocessor should check that the sum of the probabilities is`==1`. Otherwise, if restrictions are not provided for every transition for a given regime, the preprocessor should check that the sum of the provided transition probabilities is`<1`. Regardless of the number of lags, the restrictions are specified for parameters at time`t`since the transition probability for a parameter at`t`is equal to that of the parameter at`t-1`. Preprocessor Matlab output would look like (only implemented for SBVAR version):options_.ms.ms_chain(1).regime(1).duration = 0.5; options_.ms.ms_chain(1).regime(2).duration = 2.5; options_.ms.ms_chain(1).regime(3).duration = 2.5; options_.ms.ms_chain(1).restrictions(1) = [1,3,0]; options_.ms.ms_chain(1).restrictions(2) = [3,1,0];

Preprocessor C output (only implemented for DSGE version) would consist of one object for every

`markov_switching`statement of the MarkovSwitching Class.- Transition matrix specification (for future use):
ms_chain(1) = [ 0.25*a, d, 0; a, e, 0; ., ., 1 ]; ms_chain(2) = [ a, 0; ., . ];

The sum of the column must be equal to 1. The dot (.) represents the complement to 1.

## Associating Markov processes with coefficient matrices

- Default in the case of one chain: all the coefficient matrices change
- Specific matrices are linked to specific chains:
svar(coefficients, chain=1); svar(variances, chain=1); svar(constants, chain=2); // not available yet

Matlab implementation:options_.ms.ms_chain(1).svar_coefficients.equations = 'ALL'; options_.ms.ms_chain(1).svar_variances.equations = 'ALL'; options_.ms.ms_chain(2).svar_constants.equations = 'ALL';

- Specific equations are linked to specific chains:
svar(coefficients, equations=1, chain=2); svar(variances, equations=[3, 5], chain=1); svar(constants, equations=3, chain=1); // not available yet

Matlab implementation:options_.ms.ms_chain(2).svar_coefficients.equations = 1; options_.ms.ms_chain(1).svar_variances.equations = [3; 5]; options_.ms.ms_chain(1).svar_constants.equations = 3;