forked from mca91/EconometricsWithR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2-4-qe.html
604 lines (536 loc) · 53.6 KB
/
2-4-qe.html
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Introduction to Econometrics with R</title>
<meta name="description" content="Beginners with little background in statistics and econometrics often have a hard time understanding the benefits of having programming skills for learning and applying Econometrics. ‘Introduction to Econometrics with R’ is an interactive companion to the well-received textbook ‘Introduction to Econometrics’ by James H. Stock and Mark W. Watson (2015). It gives a gentle introduction to the essentials of R programming and guides students in implementing the empirical applications presented throughout the textbook using the newly aquired skills. This is supported by interactive programming exercises generated with DataCamp Light and integration of interactive visualizations of central concepts which are based on the flexible JavaScript library D3.js.">
<meta name="generator" content="bookdown and GitBook 2.6.7">
<meta property="og:title" content="Introduction to Econometrics with R" />
<meta property="og:type" content="book" />
<meta property="og:url" content="https://www.econometrics-with-r.org/" />
<meta property="og:image" content="https://www.econometrics-with-r.org/images/cover.png" />
<meta property="og:description" content="Beginners with little background in statistics and econometrics often have a hard time understanding the benefits of having programming skills for learning and applying Econometrics. ‘Introduction to Econometrics with R’ is an interactive companion to the well-received textbook ‘Introduction to Econometrics’ by James H. Stock and Mark W. Watson (2015). It gives a gentle introduction to the essentials of R programming and guides students in implementing the empirical applications presented throughout the textbook using the newly aquired skills. This is supported by interactive programming exercises generated with DataCamp Light and integration of interactive visualizations of central concepts which are based on the flexible JavaScript library D3.js." />
<meta name="github-repo" content="mca91/EconometricsWithR" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Introduction to Econometrics with R" />
<meta name="twitter:description" content="Beginners with little background in statistics and econometrics often have a hard time understanding the benefits of having programming skills for learning and applying Econometrics. ‘Introduction to Econometrics with R’ is an interactive companion to the well-received textbook ‘Introduction to Econometrics’ by James H. Stock and Mark W. Watson (2015). It gives a gentle introduction to the essentials of R programming and guides students in implementing the empirical applications presented throughout the textbook using the newly aquired skills. This is supported by interactive programming exercises generated with DataCamp Light and integration of interactive visualizations of central concepts which are based on the flexible JavaScript library D3.js." />
<meta name="twitter:image" content="https://www.econometrics-with-r.org/images/cover.png" />
<meta name="author" content="Christoph Hanck, Martin Arnold, Alexander Gerber and Martin Schmelzer">
<meta name="date" content="2018-12-03">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="prev" href="2-3-experimental-estimates-of-the-effect-of-class-size-reductions.html">
<link rel="next" href="2-5-exercises.html">
<script src="libs/jquery-2.2.3/jquery.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<!-- font families -->
<link href="https://fonts.googleapis.com/css?family=PT+Sans|Pacifico|Source+Sans+Pro" rel="stylesheet">
<script src="js/hideOutput.js"></script>
<!-- Mathjax -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/default.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js"],
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]},
jax: ["input/TeX","output/CommonHTML"]
});
MathJax.Hub.processSectionDelay = 0;
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-110299877-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-110299877-1');
</script>
<!-- open review block -->
<script async defer src="https://hypothes.is/embed.js"></script>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; background-color: #f8f8f8; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
pre, code { background-color: #f8f8f8; }
code > span.kw { color: #204a87; font-weight: bold; } /* Keyword */
code > span.dt { color: #204a87; } /* DataType */
code > span.dv { color: #0000cf; } /* DecVal */
code > span.bn { color: #0000cf; } /* BaseN */
code > span.fl { color: #0000cf; } /* Float */
code > span.ch { color: #4e9a06; } /* Char */
code > span.st { color: #4e9a06; } /* String */
code > span.co { color: #8f5902; font-style: italic; } /* Comment */
code > span.ot { color: #8f5902; } /* Other */
code > span.al { color: #ef2929; } /* Alert */
code > span.fu { color: #000000; } /* Function */
code > span.er { color: #a40000; font-weight: bold; } /* Error */
code > span.wa { color: #8f5902; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #000000; } /* Constant */
code > span.sc { color: #000000; } /* SpecialChar */
code > span.vs { color: #4e9a06; } /* VerbatimString */
code > span.ss { color: #4e9a06; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #000000; } /* Variable */
code > span.cf { color: #204a87; font-weight: bold; } /* ControlFlow */
code > span.op { color: #ce5c00; font-weight: bold; } /* Operator */
code > span.pp { color: #8f5902; font-style: italic; } /* Preprocessor */
code > span.ex { } /* Extension */
code > span.at { color: #c4a000; } /* Attribute */
code > span.do { color: #8f5902; font-weight: bold; font-style: italic; } /* Documentation */
code > span.an { color: #8f5902; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #8f5902; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #8f5902; font-weight: bold; font-style: italic; } /* Information */
</style>
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="stylesheet" href="toc.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><center><img src="images/logo.png" alt="logo" width="50%" height="50%"style="margin: 15px 0 0 0"></center></li>
<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>Preface</a></li>
<li class="chapter" data-level="1" data-path="1-introduction.html"><a href="1-introduction.html"><i class="fa fa-check"></i><b>1</b> Introduction</a><ul>
<li class="chapter" data-level="1.1" data-path="1-1-a-very-short-introduction-to-r-and-rstudio.html"><a href="1-1-a-very-short-introduction-to-r-and-rstudio.html"><i class="fa fa-check"></i><b>1.1</b> A Very Short Introduction to <tt>R</tt> and <em>RStudio</em></a></li>
</ul></li>
<li class="chapter" data-level="2" data-path="2-eaqe.html"><a href="2-eaqe.html"><i class="fa fa-check"></i><b>2</b> Experiments and Quasi-Experiments</a><ul>
<li class="chapter" data-level="2.1" data-path="2-1-poceaie.html"><a href="2-1-poceaie.html"><i class="fa fa-check"></i><b>2.1</b> Potential Outcomes, Causal Effects and Idealized Experiments</a></li>
<li class="chapter" data-level="2.2" data-path="2-2-threats-to-validity-of-experiments.html"><a href="2-2-threats-to-validity-of-experiments.html"><i class="fa fa-check"></i><b>2.2</b> Threats to Validity of Experiments</a></li>
<li class="chapter" data-level="2.3" data-path="2-3-experimental-estimates-of-the-effect-of-class-size-reductions.html"><a href="2-3-experimental-estimates-of-the-effect-of-class-size-reductions.html"><i class="fa fa-check"></i><b>2.3</b> Experimental Estimates of the Effect of Class Size Reductions</a><ul>
<li class="chapter" data-level="" data-path="2-3-experimental-estimates-of-the-effect-of-class-size-reductions.html"><a href="2-3-experimental-estimates-of-the-effect-of-class-size-reductions.html#experimental-design-and-the-data-set"><i class="fa fa-check"></i>Experimental Design and the Data Set</a></li>
<li class="chapter" data-level="" data-path="2-3-experimental-estimates-of-the-effect-of-class-size-reductions.html"><a href="2-3-experimental-estimates-of-the-effect-of-class-size-reductions.html#analysis-of-the-star-data"><i class="fa fa-check"></i>Analysis of the STAR Data</a></li>
</ul></li>
<li class="chapter" data-level="2.4" data-path="2-4-qe.html"><a href="2-4-qe.html"><i class="fa fa-check"></i><b>2.4</b> Quasi Experiments</a><ul>
<li class="chapter" data-level="" data-path="2-4-qe.html"><a href="2-4-qe.html#the-differences-in-differences-estimator"><i class="fa fa-check"></i>The Differences-in-Differences Estimator</a></li>
<li class="chapter" data-level="" data-path="2-4-qe.html"><a href="2-4-qe.html#regression-discontinuity-estimators"><i class="fa fa-check"></i>Regression Discontinuity Estimators</a></li>
</ul></li>
<li class="chapter" data-level="2.5" data-path="2-5-exercises.html"><a href="2-5-exercises.html"><i class="fa fa-check"></i><b>2.5</b> Exercises</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="references.html"><a href="references.html"><i class="fa fa-check"></i>References</a></li>
<li class="divider"></li>
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Introduction to Econometrics with R</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div class = rmdreview>
This book is in <b>Open Review</b>. We want your feedback to make the book better for you and other students. You may annotate some text by <span style="background-color: #3297FD; color: white">selecting it with the cursor</span> and then click the <i class="h-icon-annotate"></i> on the pop-up menu. You can also see the annotations of others: click the <i class="h-icon-chevron-left"></i> in the upper right hand corner of the page <i class="fa fa-arrow-circle-right fa-rotate-315" aria-hidden="true"></i>
</div>
<div id="qe" class="section level2">
<h2><span class="header-section-number">2.4</span> Quasi Experiments</h2>
<p>In quasi-experiments, “as if” randomness is exploited to use methods similar to those that have been discussed in the previous chapter. There are two types of quasi-experiments:<a href="#fn3" class="footnoteRef" id="fnref3"><sup>3</sup></a></p>
<ol style="list-style-type: decimal">
<li><p>Random variations in individual circumstances allow to view the treatment “as if” it was randomly determined.</p></li>
<li><p>The treatment is only partially determined by “as if” random variation.</p></li>
</ol>
<p>The former allows to estimate the effect using either model <a href="2-1-poceaie.html#eq:diffestwar">(2.2)</a>, i.e., the <em>difference estimator with additional regressors</em>, or, if there is doubt that the “as if” randomness does not entirely ensure that there are no systematic differences between control and treatment group, using the <em>differences-in-differences</em> (DID) estimator. In the latter case, an IV approach for estimation of a model like <a href="2-1-poceaie.html#eq:diffestwar">(2.2)</a> which uses the source of “as if” randomness in treatment assignment as the instrument may be applied.</p>
<p>Some more advanced techniques that are helpful in settings where the treatment assignment is (partially) determined by a threshold in a so-called running variable are <em>sharp regression discontinuity design</em> (RDD) and <em>fuzzy regression discontinuity design</em> (FRDD).</p>
<p>We briefly review these techniques and, since the book does not provide any empirical examples in this section, we will use our own simulated data in a minimal example to discuss how DID, RDD and FRDD can be applied in <tt>R</tt>.</p>
<div id="the-differences-in-differences-estimator" class="section level3 unnumbered">
<h3>The Differences-in-Differences Estimator</h3>
<p>In quasi-experiments the source of “as if” randomness in treatment assignment can often not entirely prevent systematic differences between control and treatment groups. This problem was encountered by <span class="citation">Card & Krueger (<a href="#ref-card1994">1994</a>)</span> who use geography as the “as if” random treatment assignment to study the effect on employment in fast-food restaurants caused by an increase in the state minimum wage in New Jersey in the year of 1992. Their idea was to use the fact that the increase in minimum wage applied to employees in New Jersey (treatment group) but not to those living in neighboring Pennsylvania (control group).</p>
<p>It is quite conceivable that such a wage hike is not correlated with other determinants of employment. However, there still might be some state-specific differences and thus differences between control and treatment group. This would render the <em>differences estimator</em> biased and inconsistent. <span class="citation">Card & Krueger (<a href="#ref-card1994">1994</a>)</span> solved this by using a DID estimator: they collected data in February 1992 (before the treatment) and November 1992 (after the treatment) for the same restaurants and estimated the effect of the wage hike by analyzing differences in the differences in employment for New Jersey and Pennsylvania before and after the increase.<a href="#fn4" class="footnoteRef" id="fnref4"><sup>4</sup></a> The DID estimator is</p>
<span class="math display" id="eq:DID">\[\begin{align}
\widehat{\beta}_1^{\text{diffs-in-diffs}} =& \, (\overline{Y}^{\text{treatment,after}} - \overline{Y}^{\text{treatment,before}}) - (\overline{Y}^{\text{control,after}} - \overline{Y}^{\text{control,before}}) \\
=& \Delta \overline{Y}^{\text{treatment}} - \Delta \overline{Y}^{\text{control}} \tag{2.8}
\end{align}\]</span>
<p>with</p>
<ul>
<li><p><span class="math inline">\(\overline{Y}^{\text{treatment,before}}\)</span> - the sample average in the treatment group before the treatment</p></li>
<li><p><span class="math inline">\(\overline{Y}^{\text{treatment,after}}\)</span> - the sample average in the treatment group after the treatment</p></li>
<li><p><span class="math inline">\(\overline{Y}^{\text{treatment,before}}\)</span> - the sample average in the control group before the treatment</p></li>
<li><p><span class="math inline">\(\overline{Y}^{\text{treatment,after}}\)</span> - the sample average in the control group after the treatment.</p></li>
</ul>
<p>We now use <tt>R</tt> to reproduce Figure 13.1 of the book.</p>
<div class="unfolded">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># initialize plot and add control group</span>
<span class="kw">plot</span>(<span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">1</span>), <span class="kw">c</span>(<span class="dv">6</span>, <span class="dv">8</span>),
<span class="dt">type =</span> <span class="st">"p"</span>,
<span class="dt">ylim =</span> <span class="kw">c</span>(<span class="dv">5</span>, <span class="dv">12</span>),
<span class="dt">xlim =</span> <span class="kw">c</span>(<span class="op">-</span><span class="fl">0.3</span>, <span class="fl">1.3</span>),
<span class="dt">main =</span> <span class="st">"The Differences-in-Differences Estimator"</span>,
<span class="dt">xlab =</span> <span class="st">"Period"</span>,
<span class="dt">ylab =</span> <span class="st">"Y"</span>,
<span class="dt">col =</span> <span class="st">"steelblue"</span>,
<span class="dt">pch =</span> <span class="dv">20</span>,
<span class="dt">xaxt =</span> <span class="st">"n"</span>,
<span class="dt">yaxt =</span> <span class="st">"n"</span>)
<span class="kw">axis</span>(<span class="dv">1</span>, <span class="dt">at =</span> <span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">1</span>), <span class="dt">labels =</span> <span class="kw">c</span>(<span class="st">"before"</span>, <span class="st">"after"</span>))
<span class="kw">axis</span>(<span class="dv">2</span>, <span class="dt">at =</span> <span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">13</span>))
<span class="co"># add treatment group</span>
<span class="kw">points</span>(<span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">1</span>, <span class="dv">1</span>), <span class="kw">c</span>(<span class="dv">7</span>, <span class="dv">9</span>, <span class="dv">11</span>),
<span class="dt">col =</span> <span class="st">"darkred"</span>,
<span class="dt">pch =</span> <span class="dv">20</span>)
<span class="co"># add line segments</span>
<span class="kw">lines</span>(<span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">1</span>), <span class="kw">c</span>(<span class="dv">7</span>, <span class="dv">11</span>), <span class="dt">col =</span> <span class="st">"darkred"</span>)
<span class="kw">lines</span>(<span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">1</span>), <span class="kw">c</span>(<span class="dv">6</span>, <span class="dv">8</span>), <span class="dt">col =</span> <span class="st">"steelblue"</span>)
<span class="kw">lines</span>(<span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">1</span>), <span class="kw">c</span>(<span class="dv">7</span>, <span class="dv">9</span>), <span class="dt">col =</span> <span class="st">"darkred"</span>, <span class="dt">lty =</span> <span class="dv">2</span>)
<span class="kw">lines</span>(<span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">1</span>), <span class="kw">c</span>(<span class="dv">9</span>, <span class="dv">11</span>), <span class="dt">col =</span> <span class="st">"black"</span>, <span class="dt">lty =</span> <span class="dv">2</span>, <span class="dt">lwd =</span> <span class="dv">2</span>)
<span class="co"># add annotations</span>
<span class="kw">text</span>(<span class="dv">1</span>, <span class="dv">10</span>, <span class="kw">expression</span>(<span class="kw">hat</span>(beta)[<span class="dv">1</span>]<span class="op">^</span>{DID}), <span class="dt">cex =</span> <span class="fl">0.8</span>, <span class="dt">pos =</span> <span class="dv">4</span>)
<span class="kw">text</span>(<span class="dv">0</span>, <span class="fl">5.5</span>, <span class="st">"s. mean control"</span>, <span class="dt">cex =</span> <span class="fl">0.8</span> , <span class="dt">pos =</span> <span class="dv">4</span>)
<span class="kw">text</span>(<span class="dv">0</span>, <span class="fl">6.8</span>, <span class="st">"s. mean treatment"</span>, <span class="dt">cex =</span> <span class="fl">0.8</span> , <span class="dt">pos =</span> <span class="dv">4</span>)
<span class="kw">text</span>(<span class="dv">1</span>, <span class="fl">7.9</span>, <span class="st">"s. mean control"</span>, <span class="dt">cex =</span> <span class="fl">0.8</span> , <span class="dt">pos =</span> <span class="dv">4</span>)
<span class="kw">text</span>(<span class="dv">1</span>, <span class="fl">11.1</span>, <span class="st">"s. mean treatment"</span>, <span class="dt">cex =</span> <span class="fl">0.8</span> , <span class="dt">pos =</span> <span class="dv">4</span>)</code></pre></div>
<p><img src="ITER_files/figure-html/unnamed-chunk-36-1.png" width="80%" style="display: block; margin: auto;" /></p>
</div>
The DID estimator <a href="2-4-qe.html#eq:DID">(2.8)</a> can also be written in regression notation: <span class="math inline">\(\widehat{\beta}_1^{\text{DID}}\)</span> is the OLS estimator of <span class="math inline">\(\beta_1\)</span> in
<span class="math display" id="eq:did">\[\begin{align}
\Delta Y_i = \beta_0 + \beta_1 X_i + u_i, \tag{2.9}
\end{align}\]</span>
<p>where <span class="math inline">\(\Delta Y_i\)</span> denotes the difference in pre- and post-treatment outcomes of individual <span class="math inline">\(i\)</span> and <span class="math inline">\(X_i\)</span> is the treatment indicator.</p>
Adding additional regressors that measure pre-treatment characteristics to <a href="2-4-qe.html#eq:did">(2.9)</a> we obtain
<span class="math display" id="eq:didwar">\[\begin{align}
\Delta Y_i = \beta_0 + \beta_1 X_i + \beta_2 W_{1i} + \dots + \beta_{1+r} W_{ri} + u_i, \tag{2.10}
\end{align}\]</span>
<p>the <em>difference-in-differences estimator</em> with additional regressors. The additional regressors may lead to a more precise estimate of <span class="math inline">\(\beta_1\)</span>.</p>
<p>We keep things simple and focus on estimation of the treatment effect using DID in the simplest case, that is a control and a treatment group observed for two time periods — one before and one after the treatment. In particular, we will see that there are three different ways to proceed.</p>
<p>First, we simulate pre- and post-treatment data using <tt>R</tt>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># set sample size</span>
n <-<span class="st"> </span><span class="dv">200</span>
<span class="co"># define treatment effect</span>
TEffect <-<span class="st"> </span><span class="dv">4</span>
<span class="co"># generate treatment dummy</span>
TDummy <-<span class="st"> </span><span class="kw">c</span>(<span class="kw">rep</span>(<span class="dv">0</span>, n<span class="op">/</span><span class="dv">2</span>), <span class="kw">rep</span>(<span class="dv">1</span>, n<span class="op">/</span><span class="dv">2</span>))
<span class="co"># simulate pre- and post-treatment values of the dependent variable</span>
y_pre <-<span class="st"> </span><span class="dv">7</span> <span class="op">+</span><span class="st"> </span><span class="kw">rnorm</span>(n)
y_pre[<span class="dv">1</span><span class="op">:</span>n<span class="op">/</span><span class="dv">2</span>] <-<span class="st"> </span>y_pre[<span class="dv">1</span><span class="op">:</span>n<span class="op">/</span><span class="dv">2</span>] <span class="op">-</span><span class="st"> </span><span class="dv">1</span>
y_post <-<span class="st"> </span><span class="dv">7</span> <span class="op">+</span><span class="st"> </span><span class="dv">2</span> <span class="op">+</span><span class="st"> </span>TEffect <span class="op">*</span><span class="st"> </span>TDummy <span class="op">+</span><span class="st"> </span><span class="kw">rnorm</span>(n)
y_post[<span class="dv">1</span><span class="op">:</span>n<span class="op">/</span><span class="dv">2</span>] <-<span class="st"> </span>y_post[<span class="dv">1</span><span class="op">:</span>n<span class="op">/</span><span class="dv">2</span>] <span class="op">-</span><span class="st"> </span><span class="dv">1</span> </code></pre></div>
<p>Next plot the data. The function <tt>jitter()</tt> is used to add some artificial dispersion in the horizontal component of the points so that there is less overplotting. The function <tt>alpha()</tt> from the package <tt>scales</tt> allows to adjust the opacity of colors used in plots.</p>
<div class="unfolded">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(scales)
pre <-<span class="st"> </span><span class="kw">rep</span>(<span class="dv">0</span>, <span class="kw">length</span>(y_pre[TDummy<span class="op">==</span><span class="dv">0</span>]))
post <-<span class="st"> </span><span class="kw">rep</span>(<span class="dv">1</span>, <span class="kw">length</span>(y_pre[TDummy<span class="op">==</span><span class="dv">0</span>]))
<span class="co"># plot control group in t=1</span>
<span class="kw">plot</span>(<span class="kw">jitter</span>(pre, <span class="fl">0.6</span>),
y_pre[TDummy <span class="op">==</span><span class="st"> </span><span class="dv">0</span>],
<span class="dt">ylim =</span> <span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">16</span>),
<span class="dt">col =</span> <span class="kw">alpha</span>(<span class="st">"steelblue"</span>, <span class="fl">0.3</span>),
<span class="dt">pch =</span> <span class="dv">20</span>,
<span class="dt">xlim =</span> <span class="kw">c</span>(<span class="op">-</span><span class="fl">0.5</span>, <span class="fl">1.5</span>),
<span class="dt">ylab =</span> <span class="st">"Y"</span>,
<span class="dt">xlab =</span> <span class="st">"Period"</span>,
<span class="dt">xaxt =</span> <span class="st">"n"</span>,
<span class="dt">main =</span> <span class="st">"Artificial Data for DID Estimation"</span>)
<span class="kw">axis</span>(<span class="dv">1</span>, <span class="dt">at =</span> <span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">1</span>), <span class="dt">labels =</span> <span class="kw">c</span>(<span class="st">"before"</span>, <span class="st">"after"</span>))
<span class="co"># add treatment group in t=1</span>
<span class="kw">points</span>(<span class="kw">jitter</span>(pre, <span class="fl">0.6</span>),
y_pre[TDummy <span class="op">==</span><span class="st"> </span><span class="dv">1</span>],
<span class="dt">col =</span> <span class="kw">alpha</span>(<span class="st">"darkred"</span>, <span class="fl">0.3</span>),
<span class="dt">pch =</span> <span class="dv">20</span>)
<span class="co"># add control group in t=2</span>
<span class="kw">points</span>(<span class="kw">jitter</span>(post, <span class="fl">0.6</span>),
y_post[TDummy <span class="op">==</span><span class="st"> </span><span class="dv">0</span>],
<span class="dt">col =</span> <span class="kw">alpha</span>(<span class="st">"steelblue"</span>, <span class="fl">0.5</span>),
<span class="dt">pch =</span> <span class="dv">20</span>)
<span class="co"># add treatment group in t=2</span>
<span class="kw">points</span>(<span class="kw">jitter</span>(post, <span class="fl">0.6</span>),
y_post[TDummy <span class="op">==</span><span class="st"> </span><span class="dv">1</span>],
<span class="dt">col =</span> <span class="kw">alpha</span>(<span class="st">"darkred"</span>, <span class="fl">0.5</span>),
<span class="dt">pch =</span> <span class="dv">20</span>)</code></pre></div>
<p><img src="ITER_files/figure-html/unnamed-chunk-38-1.png" width="80%" style="display: block; margin: auto;" /></p>
</div>
<p>Observations from both the control and treatment group have a higher mean after the treatment but that the increase is stronger for the treatment group. Using DID we may estimate how much of that difference is due to the treatment.</p>
<p>It is straightforward to compute the DID estimate in the fashion of <a href="2-4-qe.html#eq:DID">(2.8)</a>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># compute the DID estimator for the treatment effect 'by hand'</span>
<span class="kw">mean</span>(y_post[TDummy <span class="op">==</span><span class="st"> </span><span class="dv">1</span>]) <span class="op">-</span><span class="st"> </span><span class="kw">mean</span>(y_pre[TDummy <span class="op">==</span><span class="st"> </span><span class="dv">1</span>]) <span class="op">-</span><span class="st"> </span>
(<span class="kw">mean</span>(y_post[TDummy <span class="op">==</span><span class="st"> </span><span class="dv">0</span>]) <span class="op">-</span><span class="st"> </span><span class="kw">mean</span>(y_pre[TDummy <span class="op">==</span><span class="st"> </span><span class="dv">0</span>]))</code></pre></div>
<pre><code>## [1] 4.215833</code></pre>
<p>Notice that the estimate is close to <span class="math inline">\(4\)</span>, the value chosen as the treatment effect <tt>TEffect</tt> above. Since <a href="2-4-qe.html#eq:did">(2.9)</a> is a simple linear model, we may perform OLS estimation of this regression specification using <tt>lm()</tt>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># compute the DID estimator using a linear model</span>
<span class="kw">lm</span>(<span class="kw">I</span>(y_post <span class="op">-</span><span class="st"> </span>y_pre) <span class="op">~</span><span class="st"> </span>TDummy)</code></pre></div>
<pre><code>##
## Call:
## lm(formula = I(y_post - y_pre) ~ TDummy)
##
## Coefficients:
## (Intercept) TDummy
## 1.958 4.216</code></pre>
We find that the estimates coincide. Furthermore, one can show that the DID estimate obtained by estimating specification <a href="2-4-qe.html#eq:did">(2.9)</a> OLS is the same as the OLS estimate of <span class="math inline">\(\beta_{TE}\)</span> in
<span class="math display" id="eq:DIDint">\[\begin{align}
Y_i =& \beta_0 + \beta_1 D_i + \beta_2 Period_i + \beta_{TE} (Period_i \times D_i) + \varepsilon_i \tag{2.11}
\end{align}\]</span>
<p>where <span class="math inline">\(D_i\)</span> is the binary treatment indicator, <span class="math inline">\(Period_i\)</span> is a binary indicator for the after-treatment period and the <span class="math inline">\(Period_i \times D_i\)</span> is the interaction of both.</p>
<p>As for <a href="2-4-qe.html#eq:did">(2.9)</a>, estimation of <a href="2-4-qe.html#eq:DIDint">(2.11)</a> using <tt>R</tt> is straightforward. See Chapter <a href="#nrf"><strong>??</strong></a> for a discussion of interaction terms.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># prepare data for DID regression using the interaction term </span>
d <-<span class="st"> </span><span class="kw">data.frame</span>(<span class="st">"Y"</span> =<span class="st"> </span><span class="kw">c</span>(y_pre,y_post),
<span class="st">"Treatment"</span> =<span class="st"> </span>TDummy,
<span class="st">"Period"</span> =<span class="st"> </span><span class="kw">c</span>(<span class="kw">rep</span>(<span class="st">"1"</span>, n), <span class="kw">rep</span>(<span class="st">"2"</span>, n)))
<span class="co"># estimate the model</span>
<span class="kw">lm</span>(Y <span class="op">~</span><span class="st"> </span>Treatment <span class="op">*</span><span class="st"> </span>Period, <span class="dt">data =</span> d)</code></pre></div>
<pre><code>##
## Call:
## lm(formula = Y ~ Treatment * Period, data = d)
##
## Coefficients:
## (Intercept) Treatment Period2
## 6.0303 0.8715 1.9585
## Treatment:Period2
## 4.2158</code></pre>
<p>As expected, the estimate of the coefficient on the interaction of the treatment dummy and the time dummy coincide with the estimates obtained using <a href="2-4-qe.html#eq:DID">(2.8)</a> and OLS estimation of <a href="2-4-qe.html#eq:did">(2.9)</a>.</p>
</div>
<div id="regression-discontinuity-estimators" class="section level3 unnumbered">
<h3>Regression Discontinuity Estimators</h3>
Consider the model
<span class="math display" id="eq:SRDDsetting">\[\begin{align}
Y_i =& \beta_0 + \beta_1 X_i + \beta_2 W_i + u_i \tag{2.12}
\end{align}\]</span>
and let
<span class="math display">\[\begin{align*}
X_i =&
\begin{cases}
1, & W_i \geq c \\
0, & W_i < c
\end{cases}
\end{align*}\]</span>
<p>so that the receipt of treatment, <span class="math inline">\(X_i\)</span>, is determined by some threshold <span class="math inline">\(c\)</span> of a continuous variable <span class="math inline">\(W_i\)</span>, the so called running variable. The idea of <em>regression discontinuity design</em> is to use observations with a <span class="math inline">\(W_i\)</span> close to <span class="math inline">\(c\)</span> for estimation of <span class="math inline">\(\beta_1\)</span>. <span class="math inline">\(\beta_1\)</span> is the average treatment effect for individuals with <span class="math inline">\(W_i = c\)</span> which is assumed to be a good approximation to the treatment effect in the population. <a href="2-4-qe.html#eq:SRDDsetting">(2.12)</a> is called a <em>sharp regression discontinuity design</em> because treatment assignment is deterministic and discontinuous at the cutoff: all observations with <span class="math inline">\(W_i < c\)</span> do not receive treatment and all observations where <span class="math inline">\(W_i \geq c\)</span> are treated.</p>
<p>The subsequent code chunks show how to estimate a linear SRDD using <tt>R</tt> and how to produce plots in the way of Figure 13.2 of the book.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># generate some sample data</span>
W <-<span class="st"> </span><span class="kw">runif</span>(<span class="dv">1000</span>, <span class="op">-</span><span class="dv">1</span>, <span class="dv">1</span>)
y <-<span class="st"> </span><span class="dv">3</span> <span class="op">+</span><span class="st"> </span><span class="dv">2</span> <span class="op">*</span><span class="st"> </span>W <span class="op">+</span><span class="st"> </span><span class="dv">10</span> <span class="op">*</span><span class="st"> </span>(W<span class="op">>=</span><span class="dv">0</span>) <span class="op">+</span><span class="st"> </span><span class="kw">rnorm</span>(<span class="dv">1000</span>)</code></pre></div>
<div class="unfolded">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># load the package 'rddtools'</span>
<span class="kw">library</span>(rddtools)
<span class="co"># construct rdd_data </span>
data <-<span class="st"> </span><span class="kw">rdd_data</span>(y, W, <span class="dt">cutpoint =</span> <span class="dv">0</span>)
<span class="co"># plot the sample data</span>
<span class="kw">plot</span>(data,
<span class="dt">col =</span> <span class="st">"steelblue"</span>,
<span class="dt">cex =</span> <span class="fl">0.35</span>,
<span class="dt">xlab =</span> <span class="st">"W"</span>,
<span class="dt">ylab =</span> <span class="st">"Y"</span>)</code></pre></div>
<p><img src="ITER_files/figure-html/unnamed-chunk-43-1.png" width="80%" style="display: block; margin: auto;" /></p>
</div>
<p>The argument <tt>nbins</tt> sets the number of bins the running variable is divided into for aggregation. The dots represent bin averages of the outcome variable.</p>
<p>We may use the function <tt>rdd_reg_lm()</tt> to estimate the treatment effect using model <a href="2-4-qe.html#eq:SRDDsetting">(2.12)</a> for the artificial data generated above. By choosing <tt>slope = “same”</tt> we restrict the slopes of the estimated regression function to be the same on both sides of the jump at the cutpoint <span class="math inline">\(W=0\)</span>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># estimate the sharp RDD model</span>
rdd_mod <-<span class="st"> </span><span class="kw">rdd_reg_lm</span>(<span class="dt">rdd_object =</span> data,
<span class="dt">slope =</span> <span class="st">"same"</span>)
<span class="kw">summary</span>(rdd_mod)</code></pre></div>
<pre><code>##
## Call:
## lm(formula = y ~ ., data = dat_step1, weights = weights)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.2491 -0.6554 -0.0125 0.6508 3.3660
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.03410 0.06947 43.68 <2e-16 ***
## D 10.06731 0.12367 81.41 <2e-16 ***
## x 1.95506 0.10722 18.23 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9775 on 997 degrees of freedom
## Multiple R-squared: 0.9745, Adjusted R-squared: 0.9745
## F-statistic: 1.905e+04 on 2 and 997 DF, p-value: < 2.2e-16</code></pre>
<p>The coefficient estimate of interest is labeled <tt>D</tt>. The estimate is very close to the treatment effect chosen in the DGP above.</p>
<p>It is easy to visualize the result: simply call <tt>plot()</tt> on the estimated model object.</p>
<div class="unfolded">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># plot the RDD model along with binned observations</span>
<span class="kw">plot</span>(rdd_mod,
<span class="dt">cex =</span> <span class="fl">0.35</span>,
<span class="dt">col =</span> <span class="st">"steelblue"</span>,
<span class="dt">xlab =</span> <span class="st">"W"</span>,
<span class="dt">ylab =</span> <span class="st">"Y"</span>)</code></pre></div>
<p><img src="ITER_files/figure-html/unnamed-chunk-45-1.png" width="80%" style="display: block; margin: auto;" /></p>
</div>
<p>As above, the dots represent averages of binned observations.</p>
<p>So far we assumed that crossing of the threshold determines receipt of treatment so that the jump of the population regression functions at the threshold can be regarded as the causal effect of the treatment.</p>
<p>When crossing the threshold <span class="math inline">\(c\)</span> is not the only cause for receipt of the treatment, treatment is not a deterministic function of <span class="math inline">\(W_i\)</span>. Instead, it is useful to think of <span class="math inline">\(c\)</span> as a threshold where the <em>probability</em> of receiving the treatment jumps.</p>
This jump may be due to unobservable variables that have impact on the probability of being treated. Thus, <span class="math inline">\(X_i\)</span> in <a href="2-4-qe.html#eq:SRDDsetting">(2.12)</a> will be correlated with the error <span class="math inline">\(u_i\)</span> and it becomes more difficult to consistently estimate the treatment effect. In this setting, using a <em>fuzzy regression discontinuity design</em> which is based an IV approach may be a remedy: take the binary variable <span class="math inline">\(Z_i\)</span> as an indicator for crossing of the threshold,
<span class="math display">\[\begin{align*}
Z_i = \begin{cases}
1, & W_i \geq c \\
0, & W_i < c,
\end{cases}
\end{align*}\]</span>
<p>and assume that <span class="math inline">\(Z_i\)</span> relates to <span class="math inline">\(Y_i\)</span> only through the treatment indicator <span class="math inline">\(X_i\)</span>. Then <span class="math inline">\(Z_i\)</span> and <span class="math inline">\(u_i\)</span> are uncorrelated but <span class="math inline">\(Z_i\)</span> influences receipt of treatment so it is correlated with <span class="math inline">\(X_i\)</span>. Thus, <span class="math inline">\(Z_i\)</span> is a valid instrument for <span class="math inline">\(X_i\)</span> and <a href="2-4-qe.html#eq:SRDDsetting">(2.12)</a> can be estimated using TSLS.</p>
<p>The following code chunk generates sample data where observations with a value of the running variable <span class="math inline">\(W_i\)</span> below the cutoff <span class="math inline">\(c=0\)</span> do not receive treatment and observations with <span class="math inline">\(W_i \geq 0\)</span> do receive treatment with a probability of <span class="math inline">\(80\%\)</span> so that treatment status is only partially determined by the running variable and the cutoff. Treatment leads to an increase in <span class="math inline">\(Y\)</span> by <span class="math inline">\(2\)</span> units. Observations with <span class="math inline">\(W_i \geq 0\)</span> that do not receive treatment are called <em>no-shows</em>: think of an individual that was assigned to receive the treatment but somehow manages to avoid it.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(MASS)
<span class="co"># generate sample data</span>
mu <-<span class="st"> </span><span class="kw">c</span>(<span class="dv">0</span>, <span class="dv">0</span>)
sigma <-<span class="st"> </span><span class="kw">matrix</span>(<span class="kw">c</span>(<span class="dv">1</span>, <span class="fl">0.7</span>, <span class="fl">0.7</span>, <span class="dv">1</span>), <span class="dt">ncol =</span> <span class="dv">2</span>)
<span class="kw">set.seed</span>(<span class="dv">1234</span>)
d <-<span class="st"> </span><span class="kw">as.data.frame</span>(<span class="kw">mvrnorm</span>(<span class="dv">2000</span>, mu, sigma))
<span class="kw">colnames</span>(d) <-<span class="st"> </span><span class="kw">c</span>(<span class="st">"W"</span>, <span class="st">"Y"</span>)
<span class="co"># introduce fuzziness</span>
d<span class="op">$</span>treatProb <-<span class="st"> </span><span class="kw">ifelse</span>(d<span class="op">$</span>W <span class="op"><</span><span class="st"> </span><span class="dv">0</span>, <span class="dv">0</span>, <span class="fl">0.8</span>)
fuzz <-<span class="st"> </span><span class="kw">sapply</span>(<span class="dt">X =</span> d<span class="op">$</span>treatProb, <span class="dt">FUN =</span> <span class="cf">function</span>(x) <span class="kw">rbinom</span>(<span class="dv">1</span>, <span class="dv">1</span>, <span class="dt">prob =</span> x))
<span class="co"># treatment effect</span>
d<span class="op">$</span>Y <-<span class="st"> </span>d<span class="op">$</span>Y <span class="op">+</span><span class="st"> </span>fuzz <span class="op">*</span><span class="st"> </span><span class="dv">2</span></code></pre></div>
<p><tt>sapply()</tt> applies the function provided to <tt>FUN</tt> to every element of the argument <tt>X</tt>. Here, <tt>d$treatProb</tt> is a vector and the result is a vector, too.</p>
<p>We plot all observations and use blue color to mark individuals that did not receive the treatment and use red color for those who received the treatment.</p>
<div class="unfolded">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># generate a colored plot of treatment and control group</span>
<span class="kw">plot</span>(d<span class="op">$</span>W, d<span class="op">$</span>Y,
<span class="dt">col =</span> <span class="kw">c</span>(<span class="st">"steelblue"</span>, <span class="st">"darkred"</span>)[<span class="kw">factor</span>(fuzz)],
<span class="dt">pch=</span> <span class="dv">20</span>,
<span class="dt">cex =</span> <span class="fl">0.5</span>,
<span class="dt">xlim =</span> <span class="kw">c</span>(<span class="op">-</span><span class="dv">3</span>, <span class="dv">3</span>),
<span class="dt">ylim =</span> <span class="kw">c</span>(<span class="op">-</span><span class="fl">3.5</span>, <span class="dv">5</span>),
<span class="dt">xlab =</span> <span class="st">"W"</span>,
<span class="dt">ylab =</span> <span class="st">"Y"</span>)
<span class="co"># add a dashed vertical line at cutoff</span>
<span class="kw">abline</span>(<span class="dt">v =</span> <span class="dv">0</span>, <span class="dt">lty =</span> <span class="dv">2</span>)</code></pre></div>
<p><img src="ITER_files/figure-html/unnamed-chunk-47-1.png" width="80%" style="display: block; margin: auto;" /></p>
</div>
<p>Obviously, receipt of treatment is no longer a deterministic function of the running variable <span class="math inline">\(W\)</span>. Some observations with <span class="math inline">\(W\geq0\)</span> <em>did not</em> receive the treatment. We may estimate a FRDD by additionally setting <tt>treatProb</tt> as the assignment variable <tt>z</tt> in <tt>rdd_data()</tt>. Then <tt>rdd_reg_lm()</tt> applies the following TSLS procedure: treatment is predicted using <span class="math inline">\(W_i\)</span> and the cutoff dummy <span class="math inline">\(Z_i\)</span>, the instrumental variable, in the first stage regression. The fitted values from the first stage regression are used to obtain a consistent estimate of the treatment effect using the second stage where the outcome <span class="math inline">\(Y\)</span> is regressed on the fitted values and the running variable <span class="math inline">\(W\)</span>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># estimate the Fuzzy RDD</span>
data <-<span class="st"> </span><span class="kw">rdd_data</span>(d<span class="op">$</span>Y, d<span class="op">$</span>W,
<span class="dt">cutpoint =</span> <span class="dv">0</span>,
<span class="dt">z =</span> d<span class="op">$</span>treatProb)
frdd_mod <-<span class="st"> </span><span class="kw">rdd_reg_lm</span>(<span class="dt">rdd_object =</span> data,
<span class="dt">slope =</span> <span class="st">"same"</span>)
frdd_mod</code></pre></div>
<pre><code>## ### RDD regression: parametric ###
## Polynomial order: 1
## Slopes: same
## Number of obs: 2000 (left: 999, right: 1001)
##
## Coefficient:
## Estimate Std. Error t value Pr(>|t|)
## D 1.981297 0.084696 23.393 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<p>The estimate is close to <span class="math inline">\(2\)</span>, the population treatment effect. We may call <tt>plot()</tt> on the model object to obtain a figure consisting of binned data and the estimated regression function.</p>
<div class="unfolded">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># plot estimated FRDD function</span>
<span class="kw">plot</span>(frdd_mod,
<span class="dt">cex =</span> <span class="fl">0.5</span>,
<span class="dt">lwd =</span> <span class="fl">0.4</span>,
<span class="dt">xlim =</span> <span class="kw">c</span>(<span class="op">-</span><span class="dv">4</span>, <span class="dv">4</span>),
<span class="dt">ylim =</span> <span class="kw">c</span>(<span class="op">-</span><span class="fl">3.5</span>, <span class="dv">5</span>),
<span class="dt">xlab =</span> <span class="st">"W"</span>,
<span class="dt">ylab =</span> <span class="st">"Y"</span>)</code></pre></div>
<p><img src="ITER_files/figure-html/unnamed-chunk-49-1.png" width="80%" style="display: block; margin: auto;" /></p>
</div>
<p>What if we used a SRDD instead, thereby ignoring the fact that treatment is not perfectly determined by the cutoff in <span class="math inline">\(W\)</span>? We may get an impression of the consequences by estimating an SRDD using the previously simulated data.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># estimate SRDD</span>
data <-<span class="st"> </span><span class="kw">rdd_data</span>(d<span class="op">$</span>Y,
d<span class="op">$</span>W,
<span class="dt">cutpoint =</span> <span class="dv">0</span>)
srdd_mod <-<span class="st"> </span><span class="kw">rdd_reg_lm</span>(<span class="dt">rdd_object =</span> data,
<span class="dt">slope =</span> <span class="st">"same"</span>)
srdd_mod</code></pre></div>
<pre><code>## ### RDD regression: parametric ###
## Polynomial order: 1
## Slopes: same
## Number of obs: 2000 (left: 999, right: 1001)
##
## Coefficient:
## Estimate Std. Error t value Pr(>|t|)
## D 1.585038 0.067756 23.393 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<p>The estimate obtained using a SRDD is suggestive of a substantial downward bias. In fact, this procedure is inconsistent for the true causal effect so increasing the sample would not alleviate the bias.</p>
<p>The book continues with a discussion of potential problems with quasi-experiments. As for all empirical studies, these potential problems are related to internal and external validity. This part is followed by a technical discussion of treatment effect estimation when the causal effect of treatment is heterogeneous in the population. We encourage you to work on these sections on your own.</p>
<div id="summary" class="section level4 unnumbered">
<h4>Summary</h4>
<p>This chapter has introduced the concept of causal effects in randomized controlled experiments and quasi-experiments where variations in circumstances or accidents of nature are treated as sources of “as if” random assignment to treatment. We have also discussed methods that allow for consistent estimation of these effects in both settings. These included the <em>differences estimator</em>, the <em>differences-in-differences estimator</em> as well as <em>sharp</em> and <em>fuzzy regression discontinuity design</em> estimators. It was shown how to apply these estimation techniques in <tt>R</tt>.</p>
<p>In an empirical application we have shown how to replicate the results of the analysis of the STAR data presented in Chapter 13.3 of the book using <tt>R</tt>. This study uses a randomized controlled experiment to assess whether smaller classes improve students’ performance on standardized tests. Being related to a randomized controlled experiment, the data of this study is fundamentally different to those used in the cross-section studies in Chapters <a href="#lrwor"><strong>??</strong></a> to <a href="#nrf"><strong>??</strong></a>. We therefore have motivated usage of a <em>differences estimator</em>.</p>
<p>Chapter <a href="#attdfc"><strong>??</strong></a> demonstrated how estimates of treatment effects can be obtained when the design of the study is a quasi-experiment that allows for <em>differences-in-differences</em> or <em>regression discontinuity design</em> estimators. In particular, we have introduced functions of the package <tt>rddtools</tt> that are convenient for estimation as well as graphical analysis when estimating a regression discontinuity design.</p>
</div>
</div>
</div>
<h3>References</h3>
<div id="refs" class="references">
<div id="ref-card1994">
<p>Card, D., & Krueger, A. B. (1994). Minimum Wages and Employment: A Case Study of the Fast-Food Industry in New Jersey and Pennsylvania. <em>The American Economic Review</em>, <em>84</em>(4), 772–793.</p>
</div>
</div>
<div class="footnotes">
<hr />
<ol start="3">
<li id="fn3"><p>See Chapter 13.4 of the book for some example studies that are based on quasi-experiments.<a href="2-4-qe.html#fnref3">↩</a></p></li>
<li id="fn4"><p>Also see the box <em>What is the Effect on Employment of the Minimum Wage?</em> in Chapter 13.4 of the book.<a href="2-4-qe.html#fnref4">↩</a></p></li>
</ol>
</div>
</section>
</div>
</div>
</div>
<a href="2-3-experimental-estimates-of-the-effect-of-class-size-reductions.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="2-5-exercises.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
</div>
</div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/lunr.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": true,
"facebook": true,
"twitter": true,
"google": false,
"linkedin": true,
"weibo": false,
"instapaper": false,
"vk": false,
"all": ["facebook", "google", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "serif",
"size": 2
},
"edit": {
"link": "https://github.com/mca91/EconometricsWithR/edit/master/13-ch13.Rmd",
"text": "Edit"
},
"history": {
"link": null,
"text": null
},
"download": ["ITER.pdf"],
"toc": {
"collapse": "subsection",
"scroll_highlight": true
}
});
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
var src = "";
if (src === "" || src === "true") src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML";
if (location.protocol !== "file:" && /^https?:/.test(src))
src = src.replace(/^https?:/, '');
script.src = src;
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>