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

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

Unread post by TomDoan »

I'm not sure where you got the code for using flipper, but you're multiplying it by a matrix that isn't used in the impulse responses. What you want is something like:

compute flipper=||1.0,1.0,-1.0||
compute factor=%decomp(sigmav(2)),factor=factor*inv(%diag(%xdiag(factor)))
compute factor=factor*%diag(flipper)

As written, this will make the impact of shock 3 on the interest rate negative, and the impact of shock 1 on hpp and shock 2 on gdpp positive.

If you want to do confidence bands, use the MCMC version.
zipop
Posts: 17
Joined: Thu Sep 05, 2013 4:52 am

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

Unread post by zipop »

TomDoan wrote:I'm not sure where you got the code for using flipper, but you're multiplying it by a matrix that isn't used in the impulse responses. What you want is something like:

compute flipper=||1.0,1.0,-1.0||
compute factor=%decomp(sigmav(2)),factor=factor*inv(%diag(%xdiag(factor)))
compute factor=factor*%diag(flipper)

As written, this will make the impact of shock 3 on the interest rate negative, and the impact of shock 1 on hpp and shock 2 on gdpp positive.

If you want to do confidence bands, use the MCMC version.
Dear Tom:
I would like to modify the mcmc version of regime dependent IRF code to impose the first series to be weakly exogenous i.e. that this series equation will not contains the lags of others. in the standard var model i would use the litherman prior like this.

declare rect priormat(nvar,nvar)
input priormat

1.0 1.e-100 1.e-100
0.5 1.0 0.5
0.5 0.5 1.0

can i just do the same here?
thanks
zipop
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

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

Unread post by TomDoan »

zipop wrote: Dear Tom:
I would like to modify the mcmc version of regime dependent IRF code to impose the first series to be weakly exogenous i.e. that this series equation will not contains the lags of others. in the standard var model i would use the litherman prior like this.

declare rect priormat(nvar,nvar)
input priormat

1.0 1.e-100 1.e-100
0.5 1.0 0.5
0.5 0.5 1.0

can i just do the same here?
thanks
zipop
This is the location where the coefficients are drawn for the VAR's. You would have to replace the HPRIOR with something appropriate to what you're doing rather than the 0's (flat prior) that is used in the code. Note that HPRIOR goes in as precisions rather than standard deviations.
do i=1,nstates
      cmom(smpl=(MSRegime==i),model=MSSysRegModel) gstart gend
      compute betasys(i)=%reshape($
          %ranmvkroncmom(%cmom,inv(sigmav(i)),hprior,bprior),nreg,nvar)
   end do i
zipop
Posts: 17
Joined: Thu Sep 05, 2013 4:52 am

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

Unread post by zipop »

thanks.
by something more appropriate which form would HPRIOR take eaxtcly in the case i would like the first series to be weakly exgonous? I was thinking then to put a higher precision on the priors on own laggs in the first equation et zeros eleswhere. this can then look as follows in a 3 lag model:
compute hprior=%zeros(nvar*nreg,nvar*nreg)
hprior(1,1:3)=||100.0,50.0,50.0||
whould this work or do i also have to change other precisions in other equations?
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 »

HPRIOR is a very large matrix. It's initialized to zero by default using:

compute hprior=%zeros(nvar*nreg,nvar*nreg)

How are you planning to handle the lag variables that aren't being excluded?
zipop
Posts: 17
Joined: Thu Sep 05, 2013 4:52 am

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

Unread post by zipop »

suppose x1, x2 and x3 are the 3 series of the var with 3 lag. then i would

have the following equations

x1=c0+c1*x1(-1)+c2*x1(-2)+c3*x1(-3)+ 0+..........+0 eq(1)

x2=d0+d1*x1(-1)+d2*x1(-2)+d3*x1(-3)+d4*x2(-1)+d5*x2(-2)+d6*x2(-3)+d7*x3(-1)+d8*x3(-2)+d9*x3(-3) eq(2)


x3=h0+d1*x1(-1)+h2*x1(-2)+h3*x1(-3)+h4*x2(-1)+h5*x2(-2)+h6*x2(-3)+h7*x3(-1)+h8*x3(-2)+h9*x3(-3) eq(3)

that is in equation (1) i would like to have zeros on the pasts of x2 and x3 but in equations (2) and (3) all the lag regressors are present but i can give more weights on own lag coefficients in eq2 and eq3. how can i parametarize HPRIOR to fits this situation? in the case of the standard VAR i would just define a general prior as

declare rect priormat(nvar,nvar)
input priormat

1.0 1.e-100 1.e-100
0.5 1.0 0.5
0.5 0.5 1.0
specify(type=general,matrix=priormat,tight=.2, DECAY=1.0) 0.5

then in eq(1) x2 and x3 have a zero weights. and in eq2 and eq3 the own lag has a higher weight and other have just a smaller weight. how can i make the same kind of parametrization using HPRIO?
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 »

Set up the prior as you would. Then estimate it over the full sample with

estimate(dummy=dd)

The hprior can be set using the "dd" matrix with:

dec vect hdiag(%nregsystem)
compute hdiag=%vec(%xsubmat(dd,1,%rows(dd)-1,1,%cols(dd)))
ewise hdiag(i)=%if(hdiag(i)==0.0,0.0,1.0/hdiag(i)^2)
compute hprior=%diag(hdiag)

The second line strips out the final row in each column (which is for the mean), the third replaces the standard errors with precisions (while replacing the hard zeroes for the constant with a zero precision).
zipop
Posts: 17
Joined: Thu Sep 05, 2013 4:52 am

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

Unread post by zipop »

thanks.

However, I was not able to create the RECTANGULAR array of dummy observations with estimate(dummy=dd). I guess the reason is because the model is estimated with nonlin (as nonlin(parmset=allparms) betasys sigmav p) and not with function estimate.

As such when i run the code it returns the following error: ## MAT17. Can't Use Row Range of 1 to -1 in %XSUBMAT operation

attached, please find the completed code and the data. how does dd should look like actually? is it an identity matrix of dimension %nregsystem?

thanks
Attachments
eev_reconstructed.rat
data file
(21.5 KiB) Downloaded 1085 times
eev_mcmc_exo.rpf
Ehrmann-Ellison-Valla(2003) with weakly exogenous variable
(7.99 KiB) Downloaded 1123 times
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 set up a VAR with the prior that you want. The ESTIMATE applies to that. Until you do an ESTIMATE, it won't be able to figure out the relative standard errors to weight the different variables.
zipop
Posts: 17
Joined: Thu Sep 05, 2013 4:52 am

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

Unread post by zipop »

thanks.
so do i have to add an estimation of the VAR in addition to using nonlin(parmset=allparms) betasys sigmav p?

how can this be done as the betasys and sigmav are already estimated?
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 »

zipop wrote:thanks.
so do i have to add an estimation of the VAR in addition to using nonlin(parmset=allparms) betasys sigmav p?

how can this be done as the betasys and sigmav are already estimated?
thanks
It's Gibbs sampling. The original betasys and sigma are just starting points for the chain---they are replaced each sweep through the sampler anyway, and the starting ones are part of the burn-in.
zipop
Posts: 17
Joined: Thu Sep 05, 2013 4:52 am

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

Unread post by zipop »

ok thanbks

i will try. what is bordering me is that at each step of the mcm residuals are drawn...both for each state and the common. no such of things are done for the standard bvar...
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

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

Unread post by TomDoan »

The residuals aren't "drawn", they're computed. What gets drawn are the sigmas, the VAR coefficients and the regimes, each conditional on the other two. The residuals are computed when needed given the VAR coefficients and the regimes.

The sigmas are drawn hierarchically because they can be a problem when there is no form of "shrinkage". That's specific to this being a regime switching model. If it weren't, you would just do a direct draw for the (one) sigma.
zipop
Posts: 17
Joined: Thu Sep 05, 2013 4:52 am

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

Unread post by zipop »

thanks.

i do not yet find the way to solve my problem. In the standard VAR approach i think the weak exogeneity assumption is used alread at the estimation stage as:


lags 1 to lags
det constant
******************************************************************
declare rect priormat(nvar,nvar)
input priormat

1.0 1.e-100 1.e-100
0.5 1.0 0.5
0.5 0.5 1.0

specify(type=general,matrix=priormat,tight=.2, DECAY=1.0) 0.5
end(system)

In the present situation the MS output which gives betasys and sigmav have not taken this into account. Thus i was wondering whether one can restrict the regressors of the first equation while seting up the MS model at this stage:

@mssysregression(states=2,switch=ch)

# logcutil logcpi logpoil
# constant logcutil{1 to 3} logcpi{1 to 3} logpoil{1 to 3}

In particulart, my question is whether it is possible to write the line # constant logcutil{1 to 3} logcpi{1 to 3} logpoil{1 to 3} for each equation?

then for the first equation i would write # constant logcutil{1 to 3} logcpi{0} logpoil{0}

but for the remaining 2 equations i would keep # constant logcutil{1 to 3} logcpi{1 to 3} logpoil{1 to 3}

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 »

Again, that doesn't matter. The initial coefficients are quickly replaced by coefficients estimated with the prior.
Post Reply