impulse response functions (irf) for a Markov-switching VAR model
resirf=msvar_irf(res,hor,arg1,...,argn)
* res = a tlist result from a ms var estimation
* hor = a scalar, the horizon of the irf (note that the shocks are supposed to happen at time 0; therefore (hor+1) impulses are calculated)
* mres = optional argument that can be:
- x = chol1 (cholesky decomposition)
- x = chol2 (triangular factorisation)
- x = original (original residuals)
(default = chol1)
* resirf = a result tlist with:
- resirf('meth') = 'msvar irf'
- resirf('msvar res') = the input ms var results tlist
- resirf('# irf') = the horizon of the irf calculations
- resirf('nb states') = the # of states
- resirf('nb irf') = the # of different AR parts
. 1 if they do not switch
. the # states if they switch
- resirf('sigma switch') = the # of switching variances
. 1 if they do not switch
. the # states if they switch
1) if both are equal to 1 then:
- resirf('irf') = the only set of impulse response function, a (nvar.hor x nvar) matrix:
[IRF(t = 0)
.
.
.
IRF(t=hor)]
with nvar = # of endogenous variables in the VAR
2) if resirf('nb states') ~= 1 or resirf('sigma switch') ~= 1 then:
- resirf('irf state # 1') until resirf('irf state # ''nstates''')=
the set of impulse response functions, each a (nvar.hor x nvar) matrix:
[IRF(t = 0)
.
.
.
IRF(t=hor)]
conditional of the original state where the process starts
load(GROCERDIR+'\data\anas.dat') bounds('1984m2','2003m1') nb_states=2; switch_var=2; var_opt=3; // the most interesting case: AR coefficients are swicthing r1=ms_var('all',2,['delts(log(ipi))' ; 'delts(log(helpwanted))' ; 'delts(log(revu))'],nb_states,switch_var,var_opt) resirf1=msvar_irf(r1,10) pltmsirf1(resirf1) // the case when only constants and variances switch r2=ms_var('const',2,['delts(log(ipi))' ; 'delts(log(helpwanted))' ; 'delts(log(revu))'],nb_states,switch_var,var_opt) resirf2=msvar_irf(r2,10) pltmsirf1(resirf2) // the case when only constants switch switch_var=1; r3=ms_var('const',2,['delts(log(ipi))' ; 'delts(log(helpwanted))' ; 'delts(log(revu))'],nb_states,switch_var,var_opt) resirf3=msvar_irf(r3,10) pltmsirf1(resirf3) | ![]() | ![]() |