Setup and Readiness
The course assumes ordinary least squares, basic instrumental variables, confidence intervals, and elementary Stata. This page installs the software and repairs the specific gaps the practica depend on. It is not a fifteenth lecture.
Software
Stata 19.5 (StataNow/SE). Every problem set and instructor build in the course was run in batch mode with StataNow/SE 19.5. Stata 18 runs the same code with lpirf available; earlier versions lack lpirf and some gmm syntax the later practica use.
Install the user-written commands the practica call:
ssc install lpdid, replace // Lecture 12: LP difference-in-differences
ssc install coefplot, replace // response graphs from stored estimates
ssc install estout, replace // tables of stored estimatesEverything else the course uses is built in: regress, newey, ivregress 2sls, gmm, simulate, lpirf, tsset, xtset.
Project layout. Every lab project unzips to a folder with master.do at the top. Run it from that folder; every path inside is relative.
cd "path/to/p01-question-to-projection-lab"
do master.doReproducibility conventions. Log every run. Set a seed before any random draw and print it. Keep raw data untouched in data/raw/. Keep generated files out of the source tree. When a browser lab and a Stata script are compared numerically, use the same input observations, exported by the lab, rather than assuming that the same seed produces the same draws in two languages.
The readiness exercise
Work through the readiness do-file before Lecture 1. It runs in under a minute and covers the four things the first practicum will assume. The file has no solutions in it; the completed version is beside it, and its log shows what a correct run prints.
1. Time-series setup, leads, lags, and missing values
clear
set obs 24
gen t = _n
tsset t
gen y = 0.7 * (t - 12)^2 / 50 + 2
replace y = . in 9 // one missing observation
gen y_lead2 = F2.y
gen y_lag1 = L1.y
list t y y_lag1 y_lead2 in 7/12Tasks. Say why y_lead2 is missing in row 7 and in rows 23 and 24, and why row 9 is still usable in a regression of F2.y on L1.y while row 10 is not. Count the rows that regression would use, then check with regress and e(N).
2. Loops, stored results, and a coefficient table
matrix results = J(4, 3, .)
forvalues h = 0/3 {
quietly regress F`h'.y L1.y
matrix results[`h' + 1, 1] = `h'
matrix results[`h' + 1, 2] = _b[L1.y]
matrix results[`h' + 1, 3] = e(N)
}
matrix colnames results = h b_lag N
matrix list resultsTasks. Explain why N falls by one each time h rises. Replace the matrix with a postfile and reproduce the same table.
3. Logs, differences, percent, and percentage points
clear
set obs 3
gen level = 100 * 1.02^(_n - 1)
gen log100 = 100 * ln(level)
gen pct_change = 100 * (level / level[_n-1] - 1)
gen logdiff = log100 - log100[_n-1]
gen rate = 4 + _n // a rate in percent: 5, 6, 7
gen rate_change_pp = rate - rate[_n-1]
listTasks. State the units of each generated column. Say in words why the change in rate is 1 percentage point and not 20 percent, and when logdiff is a good approximation to pct_change.
4. A coefficient, a counterfactual, and an interval
clear
set seed 20260913
set obs 200
gen s = rnormal()
gen y = 1.5 + 0.8 * s + rnormal(0, 2)
regress y sTasks. Write the sentence the coefficient on s supports, naming the intervention, the units, and the comparison it makes. Compute the 95 percent interval by hand from _b[s] and _se[s] and compare with the table. Say what the interval is a claim about, and what it is not.
What to bring to Lecture 1
You should be able to build the leads of an outcome, run one regression per horizon inside a loop, store the coefficient and the sample size, and say what the coefficient measures in units. That is the whole of the first problem set, with one addition the lecture supplies: what makes the coefficient a response.