DSGE with exogenous variables
Posted: Fri Feb 19, 2010 11:21 am
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)