DSGE with exogenous variables

Discussion of State Space and Dynamic Stochastic General Equilibrium Models
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

DSGE with exogenous variables

Unread post by TomDoan »

This is an example of simulating a DSGE with one of the exogenous variables subjected to a change known to the agents. It uses the ETZ option to fetch the extra matrices required for computing the shift due to this.

Code: Select all

*
* Hairault, Langot & Portier(2001). "Efficiency and stabilization:
* reducing Harberger triangles and Okun gaps," Economics Letters, vol.
* 70, no. 2, 209-214.
*
dec series Welf w c h in k z A
dec series tau
*
dec real beta delta alpha mu eta rho Abar
*
compute delta = 0.025
compute eta = 2
compute mu = 0.1
compute alpha = 0.36
compute rho = 0.95
compute beta = 0.988
compute Abar = 1
frml(identity) eqn1 = Welf  - ( log(c)+eta*log(1-h)+beta*Welf{-1})
frml(identity) eqn2 = c+in  - ( A*k{1}^alpha*h^(1-alpha))
frml(identity) eqn3 = in  - ( k - (1-delta)*k{1})
frml           eqn4 = log(A)  - ( (1-rho)*log(Abar)+rho*log(A{1}))
frml(identity) eqn5 = 1/c  - ( beta*(1/c{-1})*(z{-1}+1-delta))
frml(identity) eqn6 = eta/(1-h)  - ( w/c)
frml(identity) eqn7 = alpha*(k{1}/h)^(alpha-1)  - ( (1+mu)*(1+tau)*z)
frml(identity) eqn8 = (1-alpha)*(k{1}/h)^alpha  - ( (1+mu)*(1+tau)*w)
frml           eqn9 = tau
*
group dsge eqn1 eqn2 eqn3 eqn4 eqn5 eqn6 eqn7 eqn8 eqn9
dsge(model=dsge,a=adlm,f=fdlm,z=zdlm,etz=etz,expand=linear,steady=ss) $
   Welf<<-100 w<<0.5 c<<.6 h<<.3 in<<.4 k<<3.0 z<<.1 A<<1.0 tau<<-mu/(1+mu)
*
* This will be the steady state for the augmented system.
*
compute [vector] x0=%solve(%identity(%rows(adlm))-adlm,zdlm)
*
* tau is exogenous. It takes values -mu/(1+mu)~-.09 for the first ten
* periods and -.15 thereafter. This path is assumed to be known at t=1.
*
set tau 1 100 = %if(t<=10,-mu/(1+mu),-.15)
*
* This uses the ETZ matrices to compute the shift required for the
* presumed path for tau. This will be combined into the constant shift
* term on DLM. The first exogenous variable is the productivity shock
* (since it's from eqn4, which is listed first in the model); the second
* is tau.
*
function TauShift time
type vector TauShift
type integer time
*
local vector infsum
*
* Theoretically, this is an infinite sum. Since the tail values are
* constant, this could be done exactly with the help of an eigen
* decomposition of etz(2). However, just crunching out a long finite sum
* is quite a bit simpler to program and should be sufficiently accurate.
*
compute infsum=%zeros(3,1)
do horz=time,99
   compute infsum=infsum+etz(2)^(horz-time)*etz(3)*||0.0|tau(horz+1)||
end do h
*
* This also allows for the current term.
*
compute TauShift=etz(1)*infsum+fdlm*||0.0|tau(time)||
end TauShift
*
* Variances of the shocks. This is zeroed for tau
*
compute sw=%diag(||.01^2,0.0||)
*
* Simulate for 20 periods starting with the steady state.
*
dlm(type=simulate,x0=x0,a=adlm,f=fdlm,sw=sw,z=zdlm+TauShift(t)) 1 20 xstates
set w 1 20  = xstates(t)(2)
set c 1 20  = xstates(t)(3)
set h 1 20  = xstates(t)(4)
set in 1 20 = xstates(t)(5)
set k  1 20 = xstates(t)(6)
*
spgraph(vfields=2)
graph(header="Consumption",grid=(t==10))
# c 1 20
graph(header="Hours",grid=(t==10))
# h 1 20
spgraph(done)
ecrgap
Posts: 36
Joined: Mon May 25, 2009 10:24 am

Re: DSGE with exogenous variables

Unread post by ecrgap »

Hi Tom,

So this example can be modified to account for regime switching?

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

Re: DSGE with exogenous variables

Unread post by TomDoan »

Yes. Note that what this does is to change the "Z" term in the state-space representation

X(t)=AX(t-1)+z(t)+Fw(t)

In general, the A and F would still be time-invariant, but the z wouldn't since it would depend upon when precisely the change to the exogenous variables takes place.
ecrgap
Posts: 36
Joined: Mon May 25, 2009 10:24 am

Re: DSGE with exogenous variables

Unread post by ecrgap »

ok I see. So can this code be modified so that to allow for variation in the A matrix (in a regime switching fashion)? If this is the case I guess one will need two dsge instructions to generate the impulse responses, no? What about the dlmirf? Is there a new version of it accounting for regime switching or time variation?

Thank you
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: DSGE with exogenous variables

Unread post by TomDoan »

The "A" matrix switching would be quite different. DLMIRF wouldn't really make sense with that type of a model; you would have to apply the DLM instruction with actual data, with the A matrix governed by a formula or function that switches based upon the switching criterion.
ecrgap
Posts: 36
Joined: Mon May 25, 2009 10:24 am

Re: DSGE with exogenous variables

Unread post by ecrgap »

Ok I see. Or, I guess, if you simulate as in the above example and you specify two different A matrices for different periods in the simulation exercise.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: DSGE with exogenous variables

Unread post by TomDoan »

That's correct. You would need something like

function AFunc time
type rect AFunc
type integer time
*
if (testcondition(time) for branch 1) {
compute AFunc=A matrix on branch 1
}
else {
compute AFunc=A matrix on branch 2
}
end
*
dlm(A=AFUNC(t),other options)
ecrgap
Posts: 36
Joined: Mon May 25, 2009 10:24 am

Re: DSGE with exogenous variables

Unread post by ecrgap »

yes, thank you very much Tom.
So, basically, it's like having two separate models, i.e. two dsge instructions. So for stability, I guess, you need both to converge uniquely (i.e. Blanshard-Kahn or Sims). So as I understand the final dlm instruction that you wrote collapses them into one.

Thank you Tom
Post Reply