程序代写案例-EC 206
时间:2022-04-18
Problem Set 8
EC 206 Macroeconomic Theory II
Spring 2022
Note: Empirical and simulation exercises must be submitted with “stand-alone” code
and data.
Problem 1.
Download real GDP and seasonally-adjusted unemployment rates at quarterly frequency from 1965
Q1 to 2018 Q4.
1. Apply the Hodrick-Prescott filter and Baxter-King Bandpass filter to real GDP growth rates
and first-differenced unemployment rates and plot them together.
2. Plot the spectra for the filtered series together. Discuss the broad patterns you see.
(Hint: In STATA, you can use tsfilter hp for HP filtering and tsfilter bk for Baxter-King
filtering. In MATLAB, you can use hpfilter for HP filtering. You can write your own code for
Baxter-King filter in MATLAB. If you are going to use non-parametric approach to estimate spectra,
please use M = 20.)
Problem 2.
This problem is based on Online Appendix C of Nakamura and Steinsson (2018).
Consider the following simple New Keynesian model.
Phillips curve: pit = βEtpit+1 + κ(yt − ynt )
Aggregate demand: ∆Mt = ∆yt + pit
Monetary shock: ∆Mt = ρ∆Mt−1 + t
Productivity shock: ynt = ηt.
Assume t and ηt are i.i.d. normal. Set the parameters to β = 0.99, κ = 0.13, ρ = 0.8, σ = 0.00066,
ση = 0.007. The last two are chosen so that the contribution of ∆Mt and y
∗
t to the variance of yt is equal.
1. Use dynare to solve for the model and calculate the true impulse response of output to a one-
unit of monetary shock (t), up to 12 horizons.
1
22. Simulate 1,000 time series from the model each of length 500 data points. Estimate responses of
output to a one-unit of monetary shock (t) based on the following regressions and compare the
median IRFs for each empirical model along with the 95% confidence bands (With simulations,
this corresponds to 2.5% and 97.5% percentiles of your estimates). Also plot the true IRF in the
same graph:
(a) ADL model
∆yt = δ + αt + β∆yt−1 + ut
(b) ADL model
∆yt = δ + αt +
4∑
b=1
βb∆yt−a + ut
(c) ADL model
∆yt = δ +
6∑
a=0
αat−a + β∆yt−1 + ut
(d) ADL model
∆yt = δ +
12∑
a=0
αat−a +
4∑
b=1
βb∆yt−b + ut
(e) LP model
yt+h − yt−1 = δh + βht +W ′t−1γh + ηt+h, h = 0, . . . , 12,
where Wt−1 includes ∆yt−1.
(f) LP model
yt+h − yt−1 = δh + βht +W ′t−1γh + ηt+h, h = 0, . . . , 12,
where Wt−1 includes t−1, . . . , t−4 and ∆yt−1,∆yt−2, . . . ,∆yt−4.
(g) (Optional with extra two points!) Selected ADL model. Following Baek and Lee (2022),
select proper A and B and estimate IRFs from the selected ADL(A,B) model:
∆yt = δ +
A∑
a=0
αat−a +
B∑
b=1
βb∆yt−b + ut
Choose L via BIC for the LP model:
yt+h − yt−1 = δh + βht +
L∑
`=1
αh(L)t−` +
L∑
`=1
γh(L)∆yt−` + ηt+h, h = 0, . . . , 12,
and estimate IRFs from the selected LP model.
3Hint: Dynare solves the model for you. The solution looks like this: yt∆Mt
pit
︸ ︷︷ ︸
≡xt
=
ψ11 ψ12ψ21 ψ22
ψ31 ψ32
︸ ︷︷ ︸
≡Ψ
(
yt−1
∆Mt−1
)
+
Ω11 Ω12Ω21 Ω22
Ω31 Ω32
︸ ︷︷ ︸
≡Ω
(
t
ηt
)
︸ ︷︷ ︸
≡vt
xt = Ψxt−1 + Ωvt
Dynare stores the coefficients of the Ψ matrix in “oo .dr.ghx” and the coefficients of the Ω
matrix in “oo dr.ghu.” Note that Dynare does not store the coefficients of the variables in the
same order you declare variables. “oo .dr.inv order var” stores the order of the variables.
You can also compare coefficients of “oo .dr.ghx” and “oo dr.ghu” with those in “POLICY AND
TRANSITION FUNCTIONS” to make sure about the ordering of the variables.
You can then simulate the vector xt by generating random numbers for the vector, vt. That is,
simulate (yt, ∆Mt, pit)
′ by generating random numbers for t from N (0, 0.000662) and for ηt
from N (0, 0.0072). (You have done this in the problem set 7 with a univariate time series model.
This is just a multivariate version.)