Page 2 of 11

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

Posted: Mon Nov 04, 2013 8:25 pm
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.

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

Posted: Thu Jan 02, 2014 4:24 am
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

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

Posted: Thu Jan 02, 2014 11:54 am
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

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

Posted: Thu Jan 02, 2014 12:32 pm
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

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

Posted: Thu Jan 02, 2014 1:54 pm
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?

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

Posted: Thu Jan 02, 2014 2:19 pm
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

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

Posted: Thu Jan 02, 2014 7:14 pm
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).

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

Posted: Fri Jan 03, 2014 3:14 am
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

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

Posted: Fri Jan 03, 2014 6:15 am
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.

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

Posted: Fri Jan 03, 2014 7:02 am
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

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

Posted: Fri Jan 03, 2014 9:05 am
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.

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

Posted: Fri Jan 03, 2014 3:04 pm
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...

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

Posted: Fri Jan 03, 2014 4:51 pm
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.

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

Posted: Sat Jan 04, 2014 6:45 am
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

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

Posted: Sat Jan 04, 2014 7:38 am
by TomDoan
Again, that doesn't matter. The initial coefficients are quickly replaced by coefficients estimated with the prior.