---
title: "Problem Set 2: Weak Instruments"
subtitle: "PP5001 · Martinmas 2026"
format:
  html:
    embed-resources: true
    toc: false
  pdf:
    papersize: a4
    fontsize: 11pt
    geometry: margin=25mm
execute:
  warning: false
  error: false
jupyter: python3
---

**Due: Friday 30 October 2026, 12 noon (UK time), in Week 7.**

Submit **your completed Quarto source (.qmd) and rendered PDF** through Moodle. Use your student ID in the document. Render the whole document before submitting.

**Student ID:** [Enter your student ID]

## Download and import the data

Download the **1980 Census data** from [Professor Jaeger's research page](https://www.djaeger.org/research/) ([Stata file](https://www.djaeger.org/data/ak3039.dta)). Save `ak3039.dta` in a folder called `data` beside this notebook. The sample contains 329,509 men born in 1930–1939.

Use `pandas` to import the file. The data contain `educ` (completed years of schooling), `lnwkwage` (log weekly earnings), `qtrbirth` (quarter of birth), `newage` (quarter-adjusted age, expressed relative to age 40), `yearborn` (year of birth), and the controls `black`, `married`, `smsa`, and `division`.

**Quarter of birth is coded 0, 1, 2, 3 for the first, second, third and fourth quarters.** The variable `age` is an integer age measure expressed relative to age 40. Use **`newage`** to construct the age controls in this exercise. It contains within-year age variation.

```{python}
#| eval: false
# After downloading the data, change eval to true.
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
import linearmodels.iv as iv

data = pd.read_stata("data/ak3039.dta", convert_categoricals=False)
data["q1"] = (data["qtrbirth"] == 0).astype(int)
data["q2"] = (data["qtrbirth"] == 1).astype(int)
data["q3"] = (data["qtrbirth"] == 2).astype(int)
data["age_years"] = data["newage"] + 40
data["age_squared"] = data["age_years"] ** 2
```

## 1. Calculate the Wald estimate from sample means

Calculate mean log weekly earnings and mean schooling separately for first-quarter births and births in the other three quarters. Present the four means and the two differences in a table.

Calculate

$$\widehat\beta_1^{Wald}=\frac{\overline Y_{Q1}-\overline Y_{Q2,Q3,Q4}}{\overline D_{Q1}-\overline D_{Q2,Q3,Q4}}.$$

Use unrounded means in the calculation. Compare your estimate with **AK Table III, Panel B**. Interpret the signs of the numerator and denominator and the units of their ratio.

```{python}
# Your calculation here.
```

## 2. Reproduce the estimate using IV

Estimate log weekly earnings on an intercept and years of schooling, using `q1` as the instrument for schooling. Include no other controls in this specification and use the same observations as in part 1. Check numerical equality with your Wald calculation. Why are these two calculations equivalent?

The formula is `"lnwkwage ~ 1 + [educ ~ q1]"`. Fit it with `iv.IV2SLS.from_formula(..., data=data).fit(cov_type="unadjusted", debiased=True)`. Report the coefficient and conventional standard error. Explain why the standard error is additional information to the ratio of means.

```{python}
# Your IV regression here.
```

## 3. Use three instruments and vary the controls

Use `q1`, `q2` and `q3` as the excluded instruments, with fourth-quarter births as the reference group. Estimate the following specifications on the same sample:

| Specification | Included controls |
|:--|:--|
| A | `black`, `married`, `smsa`, and region indicators `C(division)` |
| B | A plus `age_years` |
| C | A plus `age_years` and `age_squared` |

For each specification, estimate the first stage and IV regression. Also estimate OLS using the same included controls. Use the controls in both the first stage and the outcome equation. `C(division)` includes region indicators, treating the region codes as categories.

For example, specification C uses the IV formula

```python
("lnwkwage ~ 1 + black + married + smsa + C(division) "
 "+ age_years + age_squared + [educ ~ q1 + q2 + q3]")
```

Use `.fit()` for OLS and the first stage, and `.fit(cov_type="unadjusted", debiased=True)` for IV. These choices give conventional standard errors, which assume homoskedastic disturbances, following AK. State this assumption in your table notes. Weak instruments can still make the usual IV confidence intervals unreliable.

```{python}
# Estimate each specification separately here.
```

## 4. Report the first-stage evidence

For each specification report:

- The three quarter-of-birth coefficients and their standard errors.
- A joint test that those three coefficients are zero.
- The partial $R^2$ for the three excluded instruments.
- The sample size.

If `first_stage` is your fitted first-stage model, `first_stage.f_test("q1 = q2 = q3 = 0")` carries out the joint test using that model's covariance estimator. It tests the excluded instruments together. It is different from the overall regression F when controls are present.

For partial $R^2$, also fit the restricted regression of schooling on the controls alone. If `restricted` and `first_stage` are the fitted models,

```python
partial_r2 = (restricted.ssr - first_stage.ssr) / restricted.ssr
```

The first-stage F in **BJB Table 1** also uses the conventional covariance estimator. Compare specification C with its three-instrument specification. Report partial $R^2$ clearly as either a proportion or a percentage. BJB multiplies it by 100.

```{python}
# Your first-stage diagnostics here.
```

## 5. Interpret the results

Create your own tables showing OLS and IV estimates alongside the first-stage evidence for A, B and C. You can use Claude to help format the tables from your fitted results.

Explain how adding age and age squared changes the estimated return to schooling and the first-stage evidence. Compare specification C with columns 1–2 of **BJB Table 1**. Which entries reproduce the published results? Discuss any discrepancies.

Would you have reached the same assessment by looking only at the second-stage results? Explain how age controls affect the quarter-of-birth comparison and why the size of this dataset does not settle the question of instrument strength.

Finally, distinguish the first-stage evidence from the argument for exclusion. What does the Bound–Jaeger graph add to that discussion?

Write your interpretation here.

## 6. Replication with help from Claude

Use Claude to help replicate **Angrist and Krueger (1991), Table V, columns (6) and (8)**:

- **Column (6):** 30 excluded instruments, with indicators for race, metropolitan residence, marital status, year of birth and region of residence. Age and age squared are excluded from the controls.
- **Column (8):** the same specification with age and age squared added, leaving 28 independent excluded instruments.

The instruments are quarter-of-birth indicators interacted with year-of-birth indicators. Use the same sample of 329,509 men as in the earlier parts. Provide Claude with Table V, including its notes, and your existing code. You might begin with this prompt:

> Help me extend my three-instrument replication to reproduce columns (6) and (8) of Table V in Angrist and Krueger (1991). Here is the table and my existing Python code. Explain how you construct the instruments, which controls enter each equation, and how you handle perfect multicollinearity. Use conventional standard errors to match the paper. Keep the code straightforward and explain each step.

**Check the implementation.** Verify the sample size, included controls and number of independent excluded instruments. Explain why adding age and age squared reduces that number from 30 to 28. Identify the linear dependencies involved. Check how age is measured when comparing coefficients with AK.

**Present your results.** Report the IV schooling coefficient, its conventional standard error, the first-stage F-statistic and partial $R^2$ for each specification. Compare the coefficients and standard errors with AK Table V, columns (6) and (8). Compare the first-stage statistics with **BJB Table 1, columns (4) and (6)**, respectively. Discuss any discrepancies. Give each table a title and notes identifying the sample, dependent variable, controls, instruments and standard-error assumption.

**Assess Claude's contribution.** Include your initial prompt and final working code. Briefly describe how you checked the code and any corrections you made. If no corrections were needed, explain the checks that gave you confidence in it. You do not need to submit the entire conversation.

**Interpret the comparison.** Compare these estimates with your three-instrument results. Does adding instruments make the IV estimates more credible? Explain using the first-stage evidence and the estimated effects of schooling. Account for the addition of year-of-birth controls when comparing specifications.

```{python}
# Your replication code here.
```

Write your assessment and interpretation here. Submit the completed Quarto source and rendered PDF through Moodle by the deadline above.

## AI-use declaration

Complete this declaration before submitting.

**AI tools used (including model or version, if known):** [Enter the tools used.]

**How I used them:** [Identify the questions or parts of the assignment where you used AI, and describe its contribution to your code, analysis, explanations, or presentation.]

**How I checked the work:** [Explain how you verified the code, results, and claims, and describe any corrections or revisions you made.]

I take responsibility for the accuracy of the submitted work and can explain the code and analysis it contains.
