Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Use this forum for posting example programs or short bits of sample code.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by TomDoan »

This is a rough implementation of Ehrmann, Ellison, Valla (2003), "Regime-dependent impulse response functions in a Markov-switching vector autoregression model", Economics Letters, Vol. 78, pp. 295-299. The data set is a reconstruction rather than the author's original data set (from their working paper). This does MCMC rather than bootstrapping for the generation of error bands for the IRF's. It does two sets of impulse responses at each kept draw, and "interleaves" them so there are six "shocks" for use in @MCGRAPHIRF, in order the first in regime1, first in regime 2, second in regime 1, etc.

This model is estimated several different ways as part of the Structural Breaks and Switching Models course. Note well that this is a very technically demanding type of model. If you have no experience with Markov switching models and MCMC methods, you're better off getting used to the issues on a simpler model first.

Zip with programs/data

Detailed description
nazif

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by nazif »

Dear Tom,
Is it possible to produce regime transition probabilities and also regime properties similar to original Ox code of Ehrmann?
and I come to another question when I am plotting irfs. Could you please explain to me what are irf(3,8) and irf(4,8) in the four-variable system? for example is irf(3,8) the response of the third variable to the fourth shock in the second regime?
Thanks
Nazif
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by TomDoan »

nazif wrote:Dear Tom,
Is it possible to produce regime transition probabilities and also regime properties similar to original Ox code of Ehrmann?
Sure. You have to save the draws for the P matrices and analyze them.
nazif wrote: and I come to another question when I am plotting irfs. Could you please explain to me what are irf(3,8) and irf(4,8) in the four-variable system? for example is irf(3,8) the response of the third variable to the fourth shock in the second regime?
The i in IRF(i,j) is the variable whose response is being computed. The shocks are interleaved, so j=1 and j=2 are for the first shock in the two regimes; j=3 and j=4 for the second shock, etc. So j=8 is the 4th shock, 2nd regime.
ege_man
Posts: 85
Joined: Sat Jul 07, 2012 2:39 pm

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by ege_man »

Dear Tom,
We get some referee comments for our paper they are also asking variance decompositions. Therefore I would like to ask you if there is a code to calculate regime dependent forecast error decompositions based on markov regime regime switching models. I am using version 8.1
Thanks
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by TomDoan »

ege_man wrote:Dear Tom,
We get some referee comments for our paper they are also asking variance decompositions. Therefore I would like to ask you if there is a code to calculate regime dependent forecast error decompositions based on markov regime regime switching models. I am using version 8.1
Thanks
FEVD's aren't really compatible with the IRF analysis, since the IRF's are using Cholesky factors standardized to unit variances to highlight the differences in dynamics rather than the differences in variances.

The two calculations that look like:

compute factor=%decomp(sigmav(1)),factor=factor*inv(%diag(%xdiag(factor)))
impulse(noprint,model=MSSysRegModel,results=impulses1,steps=steps,factor=factor)

would need to have IMPULSE replaced with ERRORS, and would need to use just the %DECOMP(...) factor rather than the rescaled one.
rawraw
Posts: 9
Joined: Sat Sep 28, 2013 2:29 am

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by rawraw »

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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by TomDoan »

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.
rawraw
Posts: 9
Joined: Sat Sep 28, 2013 2:29 am

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by rawraw »

Hi, tom

Could you please explain to us what does IMPULSESk(i,j) mean?(k=1,2) what is the difference between IMPULSESk(i,j) and IRF(i,j)? Thanks.

Best wishes
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by TomDoan »

IMPULSES1 are the responses in regime 1 and IMPULSES2 are the responses in regime 2. Those are generated for each draw and get combined into a single set of responses so @MCPROCESSIRF can process them together. IRF will have the medians after the post processing for the combined responses.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by TomDoan »

Just add this after the estimation is finished. This will do the responses to shocks normalized to unit impacts, as they do in the paper.

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)
rawraw
Posts: 9
Joined: Sat Sep 28, 2013 2:29 am

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by rawraw »

TomDoan wrote:Just add this after the estimation is finished. This will do the responses to shocks normalized to unit impacts, as they do in the paper.

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)
I got "## SX11. Identifier STEPS is Not Recognizable. Incorrect Option Field or Parameter Order?>>>>ulses1,steps=steps,<<<<" when I add the code after the EM estimation is finished ,what can I do next? Thanks!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by TomDoan »

You have to define STEPS as the number of steps of IRF's that you want.
rawraw
Posts: 9
Joined: Sat Sep 28, 2013 2:29 am

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by rawraw »

TomDoan wrote:You have to define STEPS as the number of steps of IRF's that you want.
Thanks!
(1) What do "k","i","j" in IMPULSES"k"(i,j) mean?
(2) I can get the IMPULSES"k"(i,j),but how can I get the IRF(i,j),LOWER(i,j),UPPER(i,j) in EM algorithm?
(3) There is only P(1,1) in results of EM estimation,so how can I get P(2,2)?P(2,2)=1-P(1,2) ?
(4) There is only BETA in results of EM estimation, how can I get BETASYS(k)(i,j)?
The code please! Thanks again.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by TomDoan »

rawraw wrote: (1) What do "k","i","j" in IMPULSES"k"(i,j) mean?
I answered about the K above. IMPULSE defines its results as an array of series where i is the target variable and j is the shock.
rawraw wrote: (2) I can get the IMPULSES"k"(i,j),but how can I get the IRF(i,j),LOWER(i,j),UPPER(i,j) in EM algorithm?
You can't. That's why we didn't put IRF's into the EM and ML programs.
rawraw wrote: (3) There is only P(1,1) in results of EM estimation,so how can I get P(2,2)?P(2,2)=1-P(1,2) ?
EM actually generates the whole matrix. It's cut down to P(1,1), P(1,2) for the ML polishing by

compute p=%xsubmat(p,1,1,1,2)

If you add

compute pmatrix=p

before that, you can then reference the whole matrix as pmatrix.
rawraw wrote: (4) There is only BETA in results of EM estimation, how can I get BETASYS(k)(i,j)?
The NONLIN needs to be changed to

nonlin(parmset=regparms) betasys sigmav
rosen
Posts: 1
Joined: Thu Oct 31, 2013 9:45 am

Re: Ehrmann-Ellison-Valla(2003) Regime-dependent IRF's

Unread post by rosen »

Dear Tom,

I am new to rats and having some problems . I am running a 3 variable ms-var simailar to ehrmann -ellison-valla(2003). I am estimating it with em. I want to generate negative shocks . My three variables are house price growth (hpp) , real gdp growth rate (gdpp) and change in monetary policy. i have attached my file. I tried the flipper option but it doesn't work. It would be great if you have a look (attached file: var4) Hi taom I have attached the data set.

My second question is is it possible to generate the standard errors using boot straps in my work.
It would be realy great if you can help me.
All the best

Rosen
Attachments
stata.csv
(8.15 KiB) Downloaded 1597 times
var4.RPF
file trying to generate negative shock
(1.96 KiB) Downloaded 1653 times
var3.RPF
(1.9 KiB) Downloaded 1594 times
Post Reply