-
Notifications
You must be signed in to change notification settings - Fork 9
/
08-class.Rmd
562 lines (359 loc) Β· 11.5 KB
/
08-class.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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
---
title: "Class 8: Diff-in-diff I"
author: "Andrew Heiss"
date: "`r Sys.Date()`"
output:
xaringan::moon_reader:
lib_dir: "libs"
chakra: "libs/remark-latest.min.js"
css: ["default", "css/ath-slides.css", "css/ath-inferno-fonts.css", "css/animate.css"]
seal: false
anchor_sections: false
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
ratio: "16:9"
navigation:
scroll: false
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(warning = FALSE, message = FALSE,
fig.retina = 3, fig.align = "center")
```
```{r packages-data, include=FALSE}
library(tidyverse)
library(ggdag)
library(palmerpenguins)
library(modelsummary)
```
```{r xaringanExtra, echo=FALSE}
xaringanExtra::use_xaringan_extra(c("tile_view"))
```
class: center middle main-title section-title-3
# In-person<br>session 8
.class-info[
**March 2, 2023**
.light[PMAP 8521: Program evaluation<br>
Andrew Young School of Policy Studies
]
]
---
name: outline
class: title title-inv-8
# Plan for today
--
.box-5.medium.sp-after-half[Models vs. designs]
--
.box-3.medium.sp-after-half[Interactions and regression]
--
.box-1.medium.sp-after-half[Simple diff-in-diff]
--
.box-6.medium.sp-after-half[Two-way fixed effects]
---
class: title title-inv-8
# Two quick things
.box-8.large.sp-after[Chunk names]
--
.box-8.large[Correct SEs for IPW]
---
layout: false
name: models-designs
class: center middle section-title section-title-5 animated fadeIn
# Models vs. designs
---
layout: true
class: middle
---
.center[
<figure>
<img src="img/08-class/2021-nobel-winners.jpg" alt="2021 econ Nobel winners" title="2021 econ Nobel winners" width="55%">
</figure>
]
???
- Card (and Krueger): NJ/PA minimum wage + the beginning of this whole credibility revolution thing
- Angrist: MHE and MM and making causal inference accessible
- Imbens: A ton of CI stuff + attempting to bridge DAG world with situation-based world
- https://twitter.com/NobelPrize/status/1447502627114205187 - PA/NJ
- https://twitter.com/MaxCRoser/status/1447505582450151431
- https://twitter.com/Stanford/status/1447549033539637248
---
.center[
<figure>
<img src="img/08-class/alan-krueger.jpg" alt="Alan Krueger" title="Alan Krueger" width="80%">
</figure>
]
???
Alan Krueger died by suicide in 2019
---
.center[
<figure>
<img src="img/08-class/pa-nj-nobel.jpg" alt="Nobel PA/NJ" title="Nobel PA/NJ" width="57%">
</figure>
]
---
layout: true
class: middle
---
.box-5.large[Design-based vs.<br>model-based inference]
.box-inv-5[Special situations vs. controlling for stuff]
---
.box-5.medium[How would you know when it is appropriate to use a quasi-experiment over an RCT?]
---
layout: true
class: title title-5
---
# Identification strategies
.box-inv-5.small.sp-after[The goal of *all* these methods is to isolate<br>(or **identify**) the arrow between treatment β outcome]
--
.box-inv-5.less-medium[Model-based identification]
.float-left.center[.box-5[DAGs] .box-5[Matching] .box-5[Inverse probability weighting]]
--
.box-inv-5.less-medium.sp-before[Design-based identification]
.float-left.center[.box-5[Randomized controlled trials] .box-5[Difference-in-differences]]
.float-left.center[.box-5[Regression discontinuity] .box-5[Instrumental variables]]
---
# Model-based identification
.box-inv-5[Use a DAG and *do*-calculus to isolate arrow]
.pull-left[
<figure>
<img src="04-slides_files/figure-html/edu-earn-adjust-1.png" alt="Education earnings DAG" title="Education earnings DAG" width="100%">
</figure>
]
.pull-right[
.box-5[Core assumption:<br>selection on observables]
.box-inv-5.small[Everything that needs to<br>be adjusted is measurable;<br>no unobserved confounding]
.box-inv-5.small[**Big assumption!**]
.box-inv-5.tiny[This is why lots of people don't like DAG-based adjustment]
]
---
layout: false
.center[
<figure>
<img src="img/08-class/charles-ozzy.png" alt="King Charles and Ozzy Osbourne" title="King Charles and Ozzy Osbourne" width="50%">
</figure>
]
---
layout: true
class: title title-5
---
# Design-based identification
.box-inv-5[Use a special situation to isolate arrow]
.pull-left[
.box-5[RCTs]
.box-inv-5.small[Use randomization<br>to remove confounding]
.center[
<figure>
<img src="05-slides_files/figure-html/experimental-dag-1.png" alt="RCT DAG" title="RCT DAG" width="60%">
</figure>
]
]
--
.pull-right[
.box-5[Difference-in-differences]
.box-inv-5.small[Use before/after & treatment/control<br>differences to remove confounding]
.center[
<figure>
<img src="08-slides_files/figure-html/min-wage-dag-1.png" alt="Diff-in-diff DAG" title="Diff-in-diff DAG" width="90%">
</figure>
]
]
---
layout: true
class: middle
---
.box-5.large[Which is better or more credible?<br>RCTs, quasi experiments,<br>or DAG-based models?]
---
.center[
<figure>
<img src="img/08-class/causality-continuum.png" alt="The (wrong!) causality continuum" title="The (wrong!) causality continuum" width="90%">
</figure>
]
---
.box-5.huge[There's no hierarchy!]
---
layout: false
name: interactions
class: center middle section-title section-title-3 animated fadeIn
# Interactions and regression
---
class: middle
.box-3.large[Can we talk more about interaction terms and how to interpret them?]
.box-3[Are interaction effects in regression always more accurate of a difference than running a "regular" regression without them?]
---
class: middle
.box-3.large[Regression is just fancy averages!]
---
layout: false
name: diff-in-diff
class: center middle section-title section-title-1 animated fadeIn
# Simple diff-in-diff
---
.center[
<figure>
<img src="img/08-class/lambeth-southwark-vauxhall.jpg" alt="Lambeth and Southwark-Vauxhall" title="Lambeth and Southwark-Vauxhall" width="70%">
</figure>
]
---
class: middle
.pull-left[
.box-1.medium[**1849**]
.box-1[Cholera deaths per 100,000]
.box-inv-1[Southwark & Vauxhall: **1,349**]
.box-inv-1[Lambeth: **847**]
]
.pull-right[
.box-1.medium[**1854**]
.box-1[Cholera deaths per 100,000]
.box-inv-1[Southwark & Vauxhall: **1,466**]
.box-inv-1[Lambeth: **193**]
]
---
.center[
<figure>
<img src="img/08-class/bedtime-math.png" alt="Bedtime math" title="Bedtime math" width="45%">
</figure>
]
---
.center[
<figure>
<img src="img/08-class/bedtime-math-diff-diff.png" alt="Bedtime math diff-in-diff" title="Bedtime math diff-in-diff" width="100%">
</figure>
]
---
layout: true
class: middle
---
.box-1.medium[When doing your subtracting to get<br>your differences in the matrix, is it better <br>to do the vertical or horizontal subtractions?]
.box-1.medium[Are there situations where<br>one is preferable to the other?]
---
.box-1.medium[Why are we learning<br>two ways to do diff-in-diff?<br>(2x2 matrix vs. `lm()`)]
---
.box-1.large[What happened to confounding??]
.box-1.large[Now we're only looking<br>at just two "confounders"?]
???
The parallel trends assumption takes care of that
---
.box-1.less-medium[What group level is best for comparison? For example, if we are looking at policy change in NJ, is it best to compare with just one or two similar states? How similar do the populations need to be?]
.box-1.medium.sp-after[Wouldn't matching be better?]
.box-1.less-medium[Do we have to think about balance when dealing with observational data in diff in diff?]
.box-inv-1[[Two-way fixed effects (TWFE)](https://www.andrewheiss.com/blog/2021/08/25/twfe-diagnostics/)]
???
- Multiple states/groups are possible - that's TWFE
- Wouldn't matching be better? Sure, if you're doing state-level stuff. But their data was restaurant level
- Balance: Maybe. With just two states/villages/countries/whatever, yes. With lots, the state/year fixed effects pick up those trends for you
---
.box-1.large[Minimum legal drinking age]
---
.center[
<figure>
<img src="img/08-class/mm-fig-5-4.png" alt="Mastering Metrics Figure 5.4" title="Mastering Metrics Figure 5.4" width="65%">
</figure>
]
---
.center[
<figure>
<img src="img/08-class/mm-fig-5-5.png" alt="Mastering Metrics Figure 5.5" title="Mastering Metrics Figure 5.5" width="65%">
</figure>
]
---
.center[
<figure>
<img src="img/08-class/mm-fig-5-6.png" alt="Mastering Metrics Figure 5.6" title="Mastering Metrics Figure 5.6" width="65%">
</figure>
]
---
.box-inv-1.medium[MLDA reduction]
.box-1.medium[Two states: Alabama vs. Arkansas]
$$\begin{aligned}
\text{Mortality}\ =&\ \beta_0 + \beta_1\ \text{Alabama} + \beta_2\ \text{After 1975}\ + \\
&\ \beta_3\ (\text{Alabama} \times \text{After 1975})
\end{aligned}$$
---
.box-inv-1.medium[Organ donations]
.box-1.medium[Two states: California vs. New Jersey]
$$\begin{aligned}
\text{Donation rate}\ =&\ \beta_0 + \beta_1\ \text{California} + \beta_2\ \text{After Q22011}\ + \\
&\ \beta_3\ (\text{California} \times \text{After Q22011})
\end{aligned}$$
---
layout: false
name: twfe
class: center middle section-title section-title-6 animated fadeIn
# Two-way fixed effects<br>(TWFE)
---
layout: true
class: middle
---
.box-6.medium[Two states: Alabama vs. Arkansas]
$$\begin{aligned}
\text{Mortality}\ =&\ \beta_0 + \beta_1\ \text{Alabama} + \beta_2\ \text{After 1975}\ + \\
&\ \beta_3\ (\text{Alabama} \times \text{After 1975})
\end{aligned}$$
---
.box-6.medium[All states: `Treatment == 1`<br>if legal for 18-20-year-olds to drink]
$$\text{Mortality}\ =\ \beta_0 + \beta_1\ \text{Treatment} + \beta_2\ \text{State} + \beta_3\ \text{Year}$$
---
$$\begin{aligned}
\text{Mortality}\ =&\ \beta_0 + \beta_1\ \text{Alabama} + \beta_2\ \text{After 1975}\ + \\
&\ \color{red}{\beta_3}\ (\text{Alabama} \times \text{After 1975})
\end{aligned}$$
.center[vs.]
$$\text{Mortality}\ =\ \beta_0 + \color{red}{\beta_1}\ \text{Treatment} + \beta_2\ \text{State} + \beta_3\ \text{Year}$$
---
$$\begin{aligned}
\text{Mortality}\ =&\ \beta_0 + \beta_1\ \text{Alabama} + \beta_2\ \text{After 1975}\ + \\
&\ \color{red}{\beta_3}\ (\text{Alabama} \times \text{After 1975})
\end{aligned}$$
.center[vs.]
$$\text{Mortality}\ =\ \beta_0 + \color{red}{\beta_1}\ \text{Treatment} + \beta_2\ \text{State} + \beta_3\ \text{Year}$$
.center[vs.]
$$\begin{aligned}
\text{Mortality}\ =\ & \beta_0 + \color{red}{\beta_1}\ \text{Treatment} + \beta_2\ \text{State} + \beta_3\ \text{Year}\ +\\
&\beta_4\ (\text{State} \times \text{Year})
\end{aligned}$$
---
.center[
<figure>
<img src="img/08-class/mm-tbl-5-2.png" alt="Mastering Metrics Table 5.2" title="Mastering Metrics Table 5.2" width="55%">
</figure>
]
---
$$\begin{aligned}
\text{Donation rate}\ =&\ \beta_0 + \beta_1\ \text{California} + \beta_2\ \text{After Q22011}\ + \\
&\ \beta_3\ (\text{California} \times \text{After Q22011})
\end{aligned}$$
.center[vs.]
$$
\begin{aligned}
\text{Donation rate}\ =\ & \beta_0 + \color{red}{\beta_1}\ \text{Treatment}\ + \\
& \beta_2\ \text{State} + \beta_3\ \text{Quarter}
\end{aligned}
$$
---
.box-6.large[What about this<br>staggered treatment stuff?]
.box-inv-6[[See this](https://www.andrewheiss.com/blog/2021/08/25/twfe-diagnostics/)]
???
This is good for ethical reasons!
Blog post
---
layout: false
name: sensitivity
class: center middle section-title section-title-2 animated fadeIn
# Sensitivity analysis
---
layout: true
class: middle
---
.box-2.medium.sp-after[How do we know when we've got<br>the right confounders in our DAG?]
.box-2.medium[How do we solve the fact that<br>we have so many unknowns in our DAG?]
---
.center[
<figure>
<img src="img/08-class/2020-2021-meme-garnick-1.jpg" alt="OVB" title="OVB" width="40%">
</figure>
]
???
https://owenozier.github.io/teaching/2020-2021-memes