-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathak91.Rmd
More file actions
118 lines (100 loc) · 3.36 KB
/
Copy pathak91.Rmd
File metadata and controls
118 lines (100 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
output: html_document
editor_options:
chunk_output_type: console
---
# Quarter of Birth and Returns to Schooling
This replicates Tables 6.4 and 6.5, and Figures 6.1 and 6.2 of *Mastering 'Metrics*.
These present an IV analysis of the returns to schooling using quarters of birth (QOB) as instruments for years of schooling [@AngristKrueger1991].
```{r setup,message=FALSE}
library("AER")
library("sandwich")
library("lmtest")
library("tidyverse")
library("broom")
```
Load `twins` data.
```{r ak91}
data("ak91", package = "masteringmetrics")
```
Some cleaning of the data.
```{r ak91-2}
ak91 <- mutate(ak91,
qob_fct = factor(qob),
q4 = as.integer(qob == "4"),
yob_fct = factor(yob))
```
Table 6.4. IV recipe for returns to schooling using a single QOB instrument.
Regress log wages on 4th quarter.
```{r mod1}
mod1 <- lm(lnw ~ q4, data = ak91)
coeftest(mod1, vcov = sandwich)
```
Regress years of schooling on 4th quarter.
```{r mod2}
mod2 <- lm(s ~ q4, data = ak91)
coeftest(mod2, vcov = sandwich)
```
IV regression of log wages on years of schooling, with 4th quarter as an instrument for years of schooling.
```{r mod3}
mod3 <- ivreg(lnw ~ s | q4, data = ak91)
coeftest(mod3, vcov = sandwich)
```
## Table 6.5
Regression Estimates of Returns to Schooling using Quarter of Birth Instruments
Column 1. OLS
```{r}
mod4 <- lm(lnw ~ s, data = ak91)
coeftest(mod4, vcov = sandwich)
```
Column 2. IV with only the 4th quarter as an instrument.
```{r}
mod5 <- ivreg(lnw ~ s | q4, data = ak91)
summary(mod5, vcov = sandwich, diagnostics = TRUE)
```
The argument `diagnostics = TRUE` will run an F-test on the first stage which is reported as the "Weak instruments" diagnostic.
Column 3. OLS. Controls for year of birth.
```{r}
mod6 <- lm(lnw ~ s + yob_fct, data = ak91)
coeftest(mod6, vcov = sandwich)
```
Column 4. IV reg using only the 4th quarter as an instrument. Controls for year of birth.
```{r}
mod7 <- ivreg(lnw ~ s + yob_fct | q4 + yob_fct, data = ak91)
summary(mod7, vcov = sandwich, diagnostics = TRUE)
```
Column 4. IV reg using all quarters as instruments. Controls for year of birth.
```{r}
mod8 <- ivreg(lnw ~ s + yob_fct | qob_fct + yob_fct, data = ak91)
summary(mod8, vcov = sandwich, diagnostics = TRUE)
```
## Figures
Summarize the average wages by age:
```{r}
ak91_age <- ak91 %>%
group_by(qob, yob) %>%
summarise(lnw = mean(lnw), s = mean(s)) %>%
mutate(q4 = (qob == 4))
```
Average years of schooling by quarter of birth for men born in 1930-39 in the 1980 US Census.
```{r}
ggplot(ak91_age, aes(x = yob + (qob - 1) / 4, y = s)) +
geom_line() +
geom_label(mapping = aes(label = qob, color = q4)) +
theme(legend.position = "none") +
scale_x_continuous("Year of birth", breaks = 1930:1940) +
scale_y_continuous("Years of Education", breaks = seq(12.2, 13.2, by = 0.2),
limits = c(12.2, 13.2))
```
Average log wages by quarter of birth for men born in 1930-39 in the 1980 US Census.
```{r}
ggplot(ak91_age, aes(x = yob + (qob - 1) / 4, y = lnw)) +
geom_line() +
geom_label(mapping = aes(label = qob, color = q4)) +
scale_x_continuous("Year of birth", breaks = 1930:1940) +
scale_y_continuous("Log weekly wages") +
theme(legend.position = "none")
```
## References {-}
- <http://masteringmetrics.com/wp-content/uploads/2015/02/ReadMe_QOB.txt>
- <http://masteringmetrics.com/wp-content/uploads/2015/02/ak91.do>