Page 5 of 11
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Fri Nov 07, 2014 2:40 pm
by TomDoan
This is the original part of the program that does the IRF's:
Code: Select all
@MSSysRegSetModel(regime=1)
compute factor=%decomp(sigmav(1)),factor=factor*inv(%diag(%xdiag(factor)))
impulse(noprint,model=MSSysRegModel,results=impulses1,steps=steps,factor=factor)
*
* Save IRF's for regime 2
*
@MSSysRegSetModel(regime=2)
compute factor=%decomp(sigmav(2)),factor=factor*inv(%diag(%xdiag(factor)))
impulse(noprint,model=MSSysRegModel,results=impulses2,steps=steps,factor=factor)
Assuming that you've defined the placeholder equation as EXOGEQ (for instance), you would want to replace the impulse instructions above with
impulse(noprint,model=MSSysRegModel+exogeq,results=impulses1,shocks=%unitv(nvar+1,nvar+1),steps=steps
and the same with results=impulses2. (The FACTOR calculations aren't needed). The rest goes through other than the set up for the graphs.
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Thu Nov 27, 2014 6:45 am
by PTillmann-436
Dear Tom,
Thanks a lot - it now goes through. When it comes to plotting the IRFs I am confused by the order of the shocks. In the Ehrmann et al. code the IRFs are numbered such that shock1 and shock2 are the shocks to the first variable in the first and the second regime, respectively. How do I get the shocks to the exogenous variable (exogeq) in both regimes?
Thanks again for your great help!
@MCProcessIRF(model=MSSysRegModel+exogeq,lower=lower,upper=upper,irf=irf)
spgraph(vfields=4,hfields=2,$
xlabels=||"Regime 1","Regime 2"||,ylabels=||"x1","x2","x3","x4"||)
do var=1,4
table(noprint) / lower(var,1) upper(var,1) lower(var,2) upper(var,2)
do shock=1,2
graph(row=var,col=shock-0,nodates) 3
# irf(var,shock)
# lower(var,shock) / 2
# upper(var,shock) / 2
end do shock
end do var
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Thu Nov 27, 2014 8:21 am
by TomDoan
If you patched that as I described, there should only be two shocks (to the exogenous variable in each regime).
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Fri Feb 27, 2015 7:38 pm
by adrangi
Hi Tom. I'm running EEV_MCMC.RPF for two variables, m0 and an equity index. No error messages, but the IRFs for regime 2 are missing, just the label "Regime 2" shows and blank below it. I got Regime 1 IRF. I added some lines for regime 2 (see below), similar to those of regime 1, however, still no IRFs! Any ideas or help will be highly appreciated. Thanks. Bahram
added lines:
set regime2 gstart gend = 0.0
set regime2 gstart gend = regime2+(MSRegime==2)
compute bgibbs(draw)=%parmspeek(allparms)
* Save IRF's for regime 2
*
@MSSysRegSetModel(regime=2)
compute factor=%decomp(sigmav(2)),factor=factor*inv(%diag(%xdiag(factor)))
impulse(noprint,model=MSSysRegModel,results=impulses2,steps=steps,factor=factor)
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Fri Feb 27, 2015 8:16 pm
by TomDoan
You copied a set of graphs for a three variable model without adapting it to two variables. With three variables, there are three variables in the outer loop and six shocks between the two regimes. With two variables, you would need to loop from 1,2 and there are only four combined shocks, so 5 and 6 aren't defined at all.
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Fri Feb 27, 2015 9:57 pm
by adrangi
Hi tom. Just was in the middle of writing to you. I changed that and it works but you'll see my new one. No IRFs for Regime 2. Thanks and sorry I was in the middle of editing when you responded. Thanks. BA
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Sat Feb 28, 2015 9:12 am
by TomDoan
The part that actually does the graphs was the part that you originally posted and it needed lots of work to adjust to two variables. It would help if you would post the entire program (add it as an attachment rather than copying and pasting).
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Sat Feb 28, 2015 12:44 pm
by adrangi
Hi Tom. Appreciate the prompt response. I'm attaching the program. No error messages. I get IRs for both under the heading regime 1, but 2 for responses of MBS (variable 1) and two for CAC (variable 2). I would tend to say both regime 1 and 2 are appearing in one graph!!! Then on the side I see the heading Regime 2, and no graphs! Thanks for checking this out. Bahram
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Sat Feb 28, 2015 12:50 pm
by TomDoan
You can just attach the RATS program without running it through Word first (which is better anyway).
First:
do shock=1,2
graph(row=var,col=shock-4,max=%maximum,min=%minimum,nodates) 3
came from code with shock=5,6 so col=shock-4 turns that into columns 1 and 2. You obviously can't do that with shock=1,2.
set regime1 gstart gend = regime1/ndraws
graph(header="MCMC Probability of Low Variance Regime")
# regime1
*
set regime2 gstart gend = regime2/ndraws
graph(header="MCMC Probability of Low Variance Regime")
# regime2
Those aren't both the low variance regime.
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Fri May 15, 2015 8:46 am
by Fadi
TomDoan wrote:rawraw wrote:Hi, tom
I am confused about "Draw 'xxxx' Redrawing regimes with regime of size 'x.xx' " in running "Draw the regimes" of the code(x means a integer),and it was still redrawing after 12 hours, i had to abort it.my model contain 3 variables, sample period:2002M02-2013M03,lag order is 2 based on hq.Thanks a million.
Best wishes
That's a rather strong indication that the second regime isn't necessary---it can't get more than five data points in one of the regimes.
Hello
I had the same problem applying this code , upon to your experience is there a solution for, or I should change the data time series dimension ?
Best regards
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Fri May 15, 2015 12:23 pm
by TomDoan
The "solution" is to accept the fact that the model is probably wrong for your data set. Is there any strong reason to believe that any form of switching model is appropriate? And if so, why would it be a (hidden state) Markov switching model?
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Sat May 16, 2015 4:48 am
by Fadi
TomDoan wrote:The "solution" is to accept the fact that the model is probably wrong for your data set. Is there any strong reason to believe that any form of switching model is appropriate? And if so, why would it be a (hidden state) Markov switching model?
Thank you for your answer
Intuitively, I expected that my data can be modelled according to one of switching models, given the study is conducted in financial market, and it is expected that the process has expected changes in the behavior related to the business cycle.
Moreover, when I tried to implement only the "mssysregression" function, I obtained estimates of parameters, VCV matrix as well as, the transition matrix probabilities for the two regime. However, an error message of "Non-invertible Matrix. Using Generalized Inverse for SYMMETRIC" is declared when I tried to draw betas by the line
"cmom(smpl=(MSRegime==i),model=MSSysRegModel) gstart gend"
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Sat May 16, 2015 11:44 am
by TomDoan
Fadi wrote:TomDoan wrote:The "solution" is to accept the fact that the model is probably wrong for your data set. Is there any strong reason to believe that any form of switching model is appropriate? And if so, why would it be a (hidden state) Markov switching model?
Thank you for your answer
Intuitively, I expected that my data can be modelled according to one of switching models, given the study is conducted in financial market, and it is expected that the process has expected changes in the behavior related to the business cycle.
Moreover, when I tried to implement only the "mssysregression" function, I obtained estimates of parameters, VCV matrix as well as, the transition matrix probabilities for the two regime. However, an error message of "Non-invertible Matrix. Using Generalized Inverse for SYMMETRIC" is declared when I tried to draw betas by the line
"cmom(smpl=(MSRegime==i),model=MSSysRegModel) gstart gend"
The difficulty is that, while you may
want the model to switch in some way related to the business cycle, there is nothing in a Markov switching model that will make that happen. You said that you got estimates from doing the maximum likelihood. However, did that produce regimes that met with your interpretation? If not, then trying to do error bands isn't going to change that.
Have you tried coming up with a measure of "the business cycle" and seeing whether or not there's a break effect related to that. Or incorporating a state of the business cycle directly into the model?
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Wed Mar 30, 2016 7:28 pm
by falcon223
Dear Tom,
I am running a four variable markov switching VAR.
I am trying to do a counter factual simulation after the VAR. To see the impact of the 4th variable on the 1st one ,setting the other two zero.
I am using the following code;
compute mixmask=||1.0,0.0,0.0,1||
compute mixonly=factor*%diag(mixmask)*inv(factor)
dec vect[series] mixshocks(4)
do t=gstart,gend
compute %pt(mixshocks,t,mixonly*%xt(vresids,t))
end do t
forecast(paths,from=gstart,to=gend,model=MSSysRegModel,results=withshocks)
# mixshocks
set mix1 = withshocks(1)
set gap = mix-mix1
I am a wondering whether I am doing the right thing.
I have attached the program file and the data .It will be great if you have a look at it.
Best regards
Rosen
Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's
Posted: Wed Mar 30, 2016 8:30 pm
by TomDoan
I'm not sure that's doing what you think it is. That can only analyze data conditional on the regime being fixed which isn't going to be true.