Page 1 of 1

How to plot IRF with MCprocessIRF

Posted: Mon Jul 01, 2019 11:14 am
by Akawa
Hello,
It's seems that the topic has been already discussed before, but I don't udnertsand how to plot IRF for Markov-switching. I get a message error related to %%responses function. I tried to udnerstand what should I do but it doesn't work.
Is it possible to guide me and tell me what piece of code i should add into the program?
Thank you very much

here the code

Code: Select all

*************************************************************************
******************* MS-VAR procedure - EM estimation*********************
*************************************************************************

******************* Initialization

open data spread_d2.xlsx
calendar(d) 2010:01:21
allocate 2013:10:01
data(format=xlsx,org=col) 2010:01:21 2013:10:01


compute gstart=2010:01:21,gend=2013:10:01

set g = set
comp glab = %label(set)

@varlagselect(Lags=6,crit=hq)
# spx set

comp varlag = 1
******************* Estimation procedure
@mssysregression(states=2,switch=ch)
# spx set
# constant spx{1 to varlag} set{1 to varlag}


nonlin(parmset=regparms) betasys sigmav
nonlin(parmset=msparms)  p

gset pt_t    = %zeros(nstates,1)
gset pt_t1   = %zeros(nstates,1)
gset psmooth = %zeros(nstates,1)


@MSSysRegInitial gstart gend


frml logl = f=%MSSysRegFVec(t),pt_t1=%mcstate(p,pstar),$
  pt_t=pstar=%msupdate(f,pt_t1,fpt),log(fpt)
maximize(start=(pstar=%MSSysRegInit()),parmset=regparms+msparms,$
  method=bfgs,iters=500,pmethod=simplex,piters=5) logl gstart gend


****************** Graphical analysis
@%mssmooth p pt_t pt_t1 psmooth
set p1smooth = psmooth(t)(1)
set shade = p1smooth>=0.5

spgraph(header="France", vfields=3,hfields=2)
graph(footer="Smoothed Probability of Regime 1",max=1.0,min=0.0,shading=shade)
# p1smooth
graph(footer="SPX",shading=shade)
# spx
graph(footer="SET",shading=shade)
# set
spgraph(done)



****************** Save IRF's for regime 1
@MSSysRegSetModel(regime=1)
compute factor=%decomp(sigmav(1)),factor=factor*inv(%diag(%xdiag(factor)))
impulse(print,model=MSSysRegModel,results=impulses1,steps=10,factor=factor)

compute factor=%decomp(sigmav(1))
errors(print,model=MSSysRegModel,results=errors1,steps=10,factor=factor)


****************** Save IRF's for regime 2
@MSSysRegSetModel(regime=2)
compute factor=%decomp(sigmav(2)),factor=factor*inv(%diag(%xdiag(factor)))
impulse(print,model=MSSysRegModel,results=impulses2,steps=10,factor=factor)

compute factor=%decomp(sigmav(2))
errors(print,model=MSSysRegModel,results=errors2,steps=10,factor=factor)


******************** Graph IRF
@MCProcessIRF(model=MSSysRegModel,lower=lower,upper=upper,irf=irf)
spgraph(footer="",vfields=3,hfields=2,$
   xlabels=||"Regime 1","Regime 2"||,ylabels=||"Cap Util","CPI","Oil Price"||)
do var=1,3
   table(noprint) / lower(var,5) upper(var,5) lower(var,6) upper(var,6)
   do shock=5,6
      graph(row=var,col=shock-4,max=%maximum,min=%minimum,nodates) 3
      # irf(var,shock)
      # lower(var,shock) / 2
      # upper(var,shock) / 2
   end do shock
end do var
spgraph(done)


Re: How to plot IRF with MCprocessIRF

Posted: Tue Jul 02, 2019 9:15 am
by TomDoan
One thing to note is that the regime-specific responses are likely only useful for a very persistent regime. (EEV discuss that point).

@MCPROCESSIRF is used after you have done some type of Monte Carlo simulation, to get confidence bands. You haven't done that in your program---the MCMC version of the EEV programs is the one that does that.

Note that the EEV paper does Cholesky factor shocks normalized to unit shocks which may not be the best choice in other situations. In their case, the variance of oil shocks is extremely high in one of the regimes---standardizing to unit shocks allows easier comparison of the dynamics---but in other sets of variables, the difference in the covariance matrices might be seen as the key different between regimes so standardizing to unit shocks would largely eliminate the signs of that.