Exercise Hints & Worked Solutions
Lecture 01
This companion is meant to be used in stages. Try the exercise first. Open the hint if you need a direction, then compare your work with the detailed solution. The solutions emphasize the reasoning behind each calculation, not only the final number.
On the website, the hints and solutions are collapsed until selected. In the PDF, every hint and solution is printed in full so the document can be read offline or used as a conventional solutions manual.
Exercises and Solutions
Exercise 1: Two paths, one difference
Problem. [core, pencil] The twelve-period economy of the notes follows y_t=0.5\,y_{t-1}+s_t+v_t with y_0=0, and its interventions fall at t=1,5,10,12. Around the second intervention the realized path is y_4=0.0625, y_5=-0.66875, y_6=-0.134375, y_7=2.0328125, and y_8=-0.28359375, and the disturbances are v_5=-1.7, v_6=0.2, v_7=2.1, and v_8=-1.3.
Build the counterfactual path y^{c}_t for t=5,\dots,8 by switching off the intervention at t=5 and nothing else. Tabulate y_t, y^{c}_t, the gap y_t-y^{c}_t, and the change since the date before, y_t-y_4.
Split each change y_t-y_4 into the causal response and the change the economy would have made without the intervention. At which dates does reading the change as the effect get the sign wrong, and by what factor does it overstate the effect at t=7?
Without repeating the recursion, give the four gaps that would result if every v_t were replaced by zero, and explain why.
Exercise 2: Iterate forward
Problem. [core, pencil] Let y_t=\rho\,y_{t-1}+\theta_0s_t+v_t, where the interventions s_t and the disturbances v_t each have mean zero, are independent over time, and are independent of each other, and |\rho|<1 (Assumptions A1–A4 of the notes).
Substitute the rule into itself to write y_{t+1} and then y_{t+2} in terms of y_{t-1} and the interventions and disturbances dated t onward. State the general formula for y_{t+h} and prove it by induction.
Change s_t by one unit while holding y_{t-1}, every disturbance, and every other intervention fixed. Derive the causal response \theta_h.
For the population regression of y_{t+h} on (1,s_t,y_{t-1}), read off \mu_h, \beta_h, \gamma_h, and the residual u_{t,h} from your formula. Show that \mathbb E[u_{t,h}]=\mathbb E[s_tu_{t,h}]=\mathbb E[y_{t-1}u_{t,h}]=0, and name the assumption each step uses.
With \theta_0=1 and \rho=0.9, compute \theta_4 and \theta_7, and find the first horizon at which the response is below half of its impact value.
Exercise 3: Rows by hand
Problem. [core, pencil] In the twelve-period economy the interventions are s_t=1 at t=1,5,10,12 and s_t=0 otherwise, and the realized outcomes are
| t | y_t | t | y_t | t | y_t |
|---|---|---|---|---|---|
| 1 | 1.9 | 5 | −0.66875 | 9 | 0.658203125 |
| 2 | 1.45 | 6 | −0.134375 | 10 | 1.9291015625 |
| 3 | 1.325 | 7 | 2.0328125 | 11 | 0.06455078125 |
| 4 | 0.0625 | 8 | −0.28359375 | 12 | 2.532275390625 |
For h=0,1,2, consider the regression of y_{t+h} on a constant and s_t, using only rows with t\ge2 so that y_{t-1} would exist in every row.
List the rows of each regression and give T_h. Check your count against T_h=T-h-p.
Identify the intervention rows and compute the mean of y_{t+h} over the intervention rows, \bar y_1, and over the other rows, \bar y_0.
Compute \hat\beta_h and compare it with \theta_h=0.5^h.
Row 4 of the h=1 regression sits in the comparison group. What is its outcome, and why is that outcome not a clean comparison?
Exercise 4: The same rows in Stata
Problem. [core, computational] Reproduce the regressions of Exercise 3 in Stata, then add the lagged outcome as a control on the same rows. Write a do-file that
enters the twelve rows of the hand table (the values of s_t and v_t are s_t=1 at t=1,5,10,12 and v_t=0.9,\,0.5,\,0.6,\,-0.6,\,-1.7,\,0.2,\,2.1,\,-1.3,\,0.8,\,0.6,\,-0.9,\,1.5), rebuilds y_t from y_t=0.5\,y_{t-1}+s_t+v_t with y_0=0, and declares the data with
tsset t;loops over h=0,1,2 with
forvalues, computes \bar y_1 and \bar y_0 withsummarize, and runsregress F`h'.y s if t >= 2with and withoutL.y, storing h, T_h, and both slopes;asserts that T_h=11-h in both regressions, that the slope without the control equals \bar y_1-\bar y_0 to within 10^{-6}, that both regressions use exactly the same rows, and that the slopes without the control equal those of Exercise 3.
Report the three slopes with the control and explain why they are no longer differences in means.
Exercise 5: One episode
Problem. [core, pencil] Replace the intervention column of the hand table by an indicator that equals 1 at t=5 and 0 at every other date, and keep the rows t\ge2 and the outcomes listed in Exercise 3.
Show that when exactly one of n rows, row \tau, has the indicator equal to 1, the least-squares slope of y_{t+h} on a constant and the indicator is y_{\tau+h}-\bar y_{\text{others}}, where \bar y_{\text{others}} is the mean outcome over the other n-1 rows.
Compute the slope at h=0,1,2 and compare each with \theta_h=0.5^h.
Use the forward equation y_{\tau+h}=\theta_h+\rho^{h+1}y_{\tau-1}+u_{\tau,h} to split the h=0 slope into \theta_0 and everything else. Which term dominates?
Return to the original intervention column (s_t=1 at t=1,5,10,12). As h grows, the regression of y_{t+h} on s_t over rows t\ge2 becomes a single-episode regression without any change to the data. At which horizon does that first happen, and what is the slope there?
Exercise 6: A response in a loop
Problem. [core, computational] The Practicum 01 lab project ships data/raw/onedraw_rho09_seed2.csv, one simulated sample of T=200 periods from y_t=0.9\,y_{t-1}+s_t+v_t with \sigma_s=\sigma_v=1 (seed 2; variables t, s, v, y). Lab 3 of the Shock-to-Response Explorer displays the same observations.
Write a do-file that loops over h=0,\dots,12, regresses y_{t+h} on a constant, s_t, and y_{t-1}, and stores h, \hat\beta_h, and T_h with
postfile.Assert that T_h=199-h, that \hat\beta_0=0.878940 and \hat\beta_{12}=-0.293297 to within 10^{-6}, and state how many of the thirteen estimates lie below \theta_h=0.9^h.
Draw the response graph with \theta_h overlaid and write a caption that names the intervention and its units, the units of the outcome, the horizon unit, and the counterfactual.
In two or three sentences, say what the graph shows about this sample and what it cannot show.
Exercise 7: Many draws
Problem. [computational] Wrap the loop of Exercise 6 in a Monte Carlo experiment. Each sample comes from y_t=\rho\,y_{t-1}+s_t+v_t with y_0=0 and s_t and v_t independent standard normal draws: 300 periods, all 300 values of s drawn before any v (generate s = rnormal(), then generate v = rnormal()), the first 100 periods discarded, so T=200. Set the seed to 3 once for each \rho\in\{0.5,0.9\}, outside the replication loop, and expose the number of replications as global R with a default of 200. In each sample, estimate \hat\beta_h for h=0,\dots,12 with y_{t-1} (199-h rows) and without it, on every row that has the lead (200-h rows).
For each \rho and h, report the mean, standard deviation, and 5th and 95th percentiles of \hat\beta_h with the control, and the mean and standard deviation without it. With R=200, assert that at \rho=0.9 and h=8 the mean and standard deviation with the control are 0.370337 and 0.211226 to within 10^{-6}.
Using the Monte Carlo standard error, the standard deviation divided by \sqrt R, decide at which horizons the mean differs from \theta_h=\rho^h by more than simulation noise.
Compare the spread with and without the control at each \rho. Explain the pattern with the variance of the term \rho^{h+1}y_{t-1} that the regression without the control leaves in its residual.
Where does the sample of Exercise 6 lie relative to the 5–95 percent band at h=8 and at h=12?
Exercise 8: What the residual contains
Problem. [core, pencil] In the AR(1) economy with \theta_0=\sigma_s=\sigma_v=1, the horizon-h residual of the regression on (1,s_t,y_{t-1}) is u_{t,h}=\sum_{j=0}^{h}\rho^{h-j}v_{t+j}+\sum_{j=1}^{h}\rho^{h-j}s_{t+j}.
Write u_{t,1} and u_{t+1,1} term by term, list the terms they share, and derive \operatorname{Corr}(u_{t,1},u_{t+1,1}) as a function of \rho.
Write u_{t,2} and u_{t+k,2} for k=1,2,3. Count the shared terms and compute \operatorname{Corr}(u_{t,2},u_{t+k,2}) at \rho=0.5 for each k.
Explain in one or two sentences why the correlation is zero beyond lag h.
Show that \mathbb E[s_tu_{t,2}\,s_{t+1}u_{t+1,2}]=0, even though u_{t,2} and u_{t+1,2} are correlated.
Exercise 9: First contact with military news
Problem. [data, computational] Ramey and Zubairy’s quarterly U.S. data are in the workbook RZDAT.xlsx, sheet rzdat, from their February 2018 replication package. The course does not redistribute the file; the Practicum 01 lab project ships data/raw/get_rz.do, which downloads it from the authors’ archive, checks its SHA-256, and prints manual download steps if the download fails. The variables you need are quarter (fractional years), rgdp (real GDP) and rgdp_pott6 (trend GDP, the series the authors call potential GDP and estimate as a sixth-degree polynomial trend in real GDP), both in billions of chained 2009 dollars at an annual rate, pgdp (the GDP deflator), and news (military news, billions of nominal dollars).
Run
get_rz.do, import the sheet, keep quarters from 1889Q1 on, and declare quarterly dates.Construct y_t=\texttt{rgdp}_t/\texttt{rgdp\_pott6}_t and s_t=\texttt{news}_t/(\texttt{rgdp\_pott6}_{t-1}\times\texttt{pgdp}_{t-1}). Assert that s_t has 504 nonmissing values.
Estimate the local projection of y_{t+h} on a constant, s_t, and y_{t-1} for h=0,\dots,20, storing \hat\beta_h and T_h. Assert T_h=504-h and explain why the formula T_h=T-h-p, applied with T=504 quarters of news and p=1, seems to predict one row fewer. Report \hat\beta_8, \hat\beta_{10}, and the peak horizon.
On the h=8 estimation sample, compute each quarter’s share of \sum_t(s_t-\bar s)^2 and list the six largest.
Re-estimate the h=8 regression without 1950Q3. Does removing Korea’s news quarter raise or lower the estimate?
Draw the response graph and write its caption. Then write a paragraph of five sentences headed “What has not yet been argued”: one sentence each on units, controls, identification, uncertainty, and dependence on a few episodes.
Exercise 10: Korea is not the average
Problem. [extra, pencil] In the Ramey–Zubairy data, GDP relative to trend was y=0.972500 in 1950Q2, and the news in 1950Q3 was s=0.600073 of lagged nominal trend GDP. Later values of y were 1.000572 in 1950Q3, 1.033931 in 1951Q3, and 1.051212 in 1953Q1. The first-contact local projection of Exercise 9 gives \hat\beta_0=0.080313, \hat\beta_4=0.259141, and \hat\beta_{10}=0.404210.
For h=0,4,10, compute the realized change y_{1950Q3+h}-y_{1950Q2} and the scaled coefficient 0.600073\,\hat\beta_h, both in units of trend GDP.
Which of the two numbers, if either, measures a gap between two paths?
Give three distinct reasons why the two numbers differ, and say what follows if both are taken at face value.