forked from jrnold/masteringmetrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdve.Rmd
92 lines (80 loc) · 2.26 KB
/
mdve.Rmd
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
# Minneapolis Domestic Violence Experiment
This replicates Table 3.3 of *Mastering 'Metrics*, which replicates the Minneapolis Domestic Violence Experiment [@ShermanBerk1984,@Angrist2006].
Load necessary packages.
```{r library,message=FALSE}
library("tidyverse")
```
Load the MDVE data.
```{r mdve}
data("mdve", package = "masteringmetrics")
```
Randomized assignments (i.e. what are police assigned to do) are in the `assigned` column.
Actual outcomes (i.e. what action do the police actually take) is in the `outcome` column.
gen outcome = "Arrest" if T_FINAL == 1
replace outcome = "Advise" if T_FINAL == 2
replace outcome = "Separate" if T_FINAL == 3
replace outcome = "Other" if T_FINAL == 4
gen total = 1
```{r}
mdve <- mutate(mdve,
assigned = case_when(
T_RANDOM == 1 ~ "Arrest",
T_RANDOM == 2 ~ "Advise",
T_RANDOM == 3 ~ "Separate"
),
outcome = case_when(
T_FINAL == 1 ~ "Arrest",
T_FINAL == 2 ~ "Advise",
T_FINAL == 3 ~ "Separate",
T_FINAL == 4 ~ "Other"
),
coddled_a = assigned != "Arrest",
coddled_o = outcome != "Arrest"
) %>%
filter(outcome != "Other")
```
Assigned and delivered treatments in the MDVE:
```{r}
mdve_summary <-
mdve %>%
count(assigned, outcome) %>%
group_by(assigned) %>%
mutate(p = n / sum(n))
print(mdve_summary, n = nrow(mdve_summary))
```
Assigned proportions in the MDVE:
```{r}
mdve_assigned <- mdve %>%
count(assigned) %>%
mutate(p = n / sum(n))
mdve_assigned
```
Delivered treatments in the MDVE:
```{r}
mdve_outcome <- mdve %>%
count(outcome) %>%
mutate(p = n / sum(n))
mdve_outcome
```
Probability of being coddled, given being assigned the coddled treatment:
```{r}
mdve_coddled <- mdve %>%
count(coddled_a, coddled_o) %>%
group_by(coddled_a) %>%
mutate(p = n / sum(n))
mdve_coddled
```
IV first stage,
$$
E[D_i | Z_i = 1] - E[D_i | Z_i = 0] .
$$
```{r}
filter(mdve_coddled, coddled_o, coddled_a)$p -
filter(mdve_coddled, coddled_o, !coddled_a)$p
```
The response variable is not provided, so the full 2SLS is not estimated here.
## References
- <http://masteringmetrics.com/wp-content/uploads/2015/02/MDVE_Table33.do>
- <http://masteringmetrics.com/wp-content/uploads/2015/02/ReadMe_MDVE.txt>
```{r include=FALSE, cache=FALSE}
```