-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresearch.html
More file actions
978 lines (932 loc) · 53.5 KB
/
research.html
File metadata and controls
978 lines (932 loc) · 53.5 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
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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.9.36">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>research – Ed Rubin</title>
<style>
/* Default styles provided by pandoc.
** See https://pandoc.org/MANUAL.html#variables-for-html for config info.
*/
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
</style>
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
<script src="site_libs/quarto-nav/headroom.min.js"></script>
<script src="site_libs/clipboard/clipboard.min.js"></script>
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
<script src="site_libs/quarto-search/fuse.min.js"></script>
<script src="site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="./">
<link href="./images/yellow-duck-512.png" rel="icon" type="image/png">
<script src="site_libs/quarto-html/quarto.js" type="module"></script>
<script src="site_libs/quarto-html/tabsets/tabsets.js" type="module"></script>
<script src="site_libs/quarto-html/popper.min.js"></script>
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
<script src="site_libs/quarto-html/anchor.min.js"></script>
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
<link href="site_libs/quarto-html/quarto-syntax-highlighting-845c23b38eaddc0f92fda52bfe77a8c8.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="site_libs/bootstrap/bootstrap-158031087360bce0ff56dc785ce39e06.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
<script src="site_libs/quarto-contrib/glightbox/glightbox.min.js"></script>
<link href="site_libs/quarto-contrib/glightbox/glightbox.min.css" rel="stylesheet">
<link href="site_libs/quarto-contrib/glightbox/lightbox.css" rel="stylesheet">
<script id="quarto-search-options" type="application/json">{
"location": "navbar",
"copy-button": false,
"collapse-after": 3,
"panel-placement": "end",
"type": "overlay",
"limit": 50,
"keyboard-shortcut": [
"f",
"/",
"s"
],
"show-item-context": false,
"language": {
"search-no-results-text": "No results",
"search-matching-documents-text": "matching documents",
"search-copy-link-title": "Copy link to search",
"search-hide-matches-text": "Hide additional matches",
"search-more-match-text": "more match in this document",
"search-more-matches-text": "more matches in this document",
"search-clear-button-title": "Clear",
"search-text-placeholder": "",
"search-detached-cancel-button-title": "Cancel",
"search-submit-button-title": "Submit",
"search-label": "Search"
}
}</script>
<link rel="stylesheet" href="styles.css">
</head>
<body class="floating nav-fixed quarto-light">
<div id="quarto-search-results"></div>
<header id="quarto-header" class="headroom fixed-top">
<nav class="navbar navbar-expand-lg " data-bs-theme="dark">
<div class="navbar-container container-fluid">
<div class="navbar-brand-container mx-auto">
<a class="navbar-brand" href="./index.html">
<span class="navbar-title">Ed Rubin</span>
</a>
</div>
<div id="quarto-search" class="" title="Search"></div>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" role="menu" aria-expanded="false" aria-label="Toggle navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav navbar-nav-scroll me-auto">
<li class="nav-item">
<a class="nav-link" href="./index.html">
<span class="menu-text">home</span></a>
</li>
<li class="nav-item">
<a class="nav-link active" href="./research.html" aria-current="page">
<span class="menu-text">research</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="./cv.html">
<span class="menu-text">cv</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="./teaching.html">
<span class="menu-text">teaching</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="./osweet.html">
<span class="menu-text">osweet</span></a>
</li>
<li class="nav-item dropdown ">
<a class="nav-link dropdown-toggle" href="#" id="nav-menu-more" role="link" data-bs-toggle="dropdown" aria-expanded="false">
<span class="menu-text">more</span>
</a>
<ul class="dropdown-menu" aria-labelledby="nav-menu-more">
<li>
<a class="dropdown-item" href="./bio.html">
<span class="dropdown-text">bio</span></a>
</li>
<li>
<a class="dropdown-item" href="https://tweeds.io">
<span class="dropdown-text">tweeds</span></a>
</li>
<li>
<a class="dropdown-item" href="./stuff.html">
<span class="dropdown-text">stuff</span></a>
</li>
<li>
<a class="dropdown-item" href="./links.html">
<span class="dropdown-text">links</span></a>
</li>
</ul>
</li>
</ul>
<ul class="navbar-nav navbar-nav-scroll ms-auto">
<li class="nav-item compact">
<a class="nav-link" href="https://github.com/edrubin"> <i class="bi bi-github" role="img">
</i>
<span class="menu-text"></span></a>
</li>
<li class="nav-item compact">
<a class="nav-link" href="./photos.html"> <i class="bi bi-camera2" role="img">
</i>
<span class="menu-text"></span></a>
</li>
</ul>
</div> <!-- /navcollapse -->
<div class="quarto-navbar-tools">
</div>
</div> <!-- /container-fluid -->
</nav>
</header>
<!-- content -->
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
<!-- sidebar -->
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">On this page</h2>
<ul>
<li><a href="#publishedaccepted" id="toc-publishedaccepted" class="nav-link active" data-scroll-target="#publishedaccepted">published/accepted</a></li>
<li><a href="#books" id="toc-books" class="nav-link" data-scroll-target="#books">books</a></li>
<li><a href="#working-papers" id="toc-working-papers" class="nav-link" data-scroll-target="#working-papers">working papers</a></li>
<li><a href="#in-progress" id="toc-in-progress" class="nav-link" data-scroll-target="#in-progress">in progress</a></li>
</ul>
</nav>
</nav>
<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar zindex-bottom">
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">research</h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<p>Abstracts and selected figures from published/accepted papers, working drafts, and in-progress projects…</p>
<p>And here’s my <a href="cv.html">CV</a> (also as <a href="cv-edward-rubin.pdf">PDF</a>).</p>
<section id="publishedaccepted" class="level2">
<h2 class="anchored" data-anchor-id="publishedaccepted">published/accepted</h2>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="https://www.pnas.org/doi/10.1073/pnas.2413013121">Glyphosate exposure and GM seed rollout unequally reduced perinatal health</a></span></p>
<p><a href="https://www.emmettsaulnier.com/">Emmett Saulnier</a> and <a href="https://edrub.in">Edward Rubin</a>. 2025. <em>Proceedings of the National Academy of Sciences (USA).</em> 122(3). <a href="https://www.pnas.org/doi/10.1073/pnas.2413013121">DOI: 2413013121</a></p>
<p><a href="https://github.com/edrubin/glyphosate-birthweight">Replication materials</a></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>The advent of herbicide-tolerant genetically modified (GM) crops spurred rapid and widespread use of the herbicide glyphosate (GLY) throughout US agriculture. In the two decades following GM-seed’s introduction, the volume of GLY applied in the US increased by more than 750%. Despite its breadth and scale, science and policy remain unresolved regarding the effects of GLY on human health. We identify the causal effect of GLY exposure on perinatal health by combining (1) county-level variation in GLY use driven by (2) the timing of the GM technology and (3) differential geographic suitability for GM crops. Our results suggest the introduction of GM seeds and GLY significantly reduced average birthweight and gestational length. While we find effects throughout the birthweight distribution, low-weight births experienced the largest reductions: the effect for births in the lowest decile is 4.5 times larger than that of the highest decile. Together, these estimates suggest that GLY exposure caused previously undocumented and unequal health costs for rural US communities over the last 20 years.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/Glyphosate/fs-main-policy-dbwt.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-1"><img src="Figures/Glyphosate/fs-main-policy-dbwt.jpeg" class="img-fluid figure-img"></a></p>
</figure>
</div>
</div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/Glyphosate/rf-main-policy-dbwt.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-2"><img src="Figures/Glyphosate/rf-main-policy-dbwt.jpeg" class="img-fluid figure-img"></a></p>
</figure>
</div>
</div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/Glyphosate/map-glyph-km2-diff-9512.jpeg" class="lightbox" data-gallery="quarto-lightbox-gallery-3"><img src="Figures/Glyphosate/map-glyph-km2-diff-9512.jpeg" class="img-fluid figure-img"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p>Coverage: <a href="https://www.science.org/content/article/common-weed-killer-may-be-harming-infants">Science</a> | <a href="https://www.newsweek.com/glyphosate-low-birth-weight-rural-counties-herbicide-2020499">Newsweek</a> | <a href="https://www.washingtonpost.com/wellness/2025/03/03/gmos-bad-glyphosate-pesticides/">Washington Post</a> | <a href="https://www.opb.org/article/2025/01/27/university-oregon-glyphosate-herbicide-health/">OPB</a> (<a href="https://podcasts.apple.com/us/podcast/university-of-oregon-study-finds-link-between-widely/id274122573?i=1000685868943">Audio: Apple Podcasts</a>) | <a href="https://news.uoregon.edu/study-links-popular-herbicide-problems-infant-health">UO News</a> | <a href="https://www.vox.com/climate/393538/rfk-jr-maha-trump-environmental-movement-far-right">Vox</a> | <a href="https://usrtk.org/pesticides/glyphosate-health-concerns/">US Right to Know</a></p>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="Papers/draft-plant-locations.pdf">Downwind and out: The strategic dispersion of power plants and their pollution</a></span></p>
<p><a href="https://www.johnmmorehouse.com">John Morehouse</a> and <a href="https://edrub.in">Edward Rubin</a>. <em>Journal of the Association of Environmental and Resource Economists</em>. <a href="https://www.journals.uchicago.edu/doi/10.1086/740146">DOI: 10.1086/740146</a></p>
<p>Replication materials: <a href="https://github.com/edrubin/plant-locations">GitHub</a> | <a href="https://doi.org/10.7910/DVN/NSCJG9">Harvard Dataverse: 10.7910/DVN/NSCJG9</a></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>US environmental policy cedes substantial authority to local agencies—creating potentials for polluters/governments to strategically export emissions. We identify such strategies among coal-fueled power plants. First, we document that electricity generators locate near administrative borders. As water influences borders/siting, we develop a simple, non-parametric test that shows coal plants located to reduce downwind exposure. Natural-gas plants—facing lower regulatory pressure—do not exhibit this behavior. Using a state-of-the-art, particle-trajectory model, we illustrate coal pollution’s extreme mobility: within 6 hours, 50% of coal plants’ emissions leave their source states—99% depart source counties. These strategic responses emphasize the importance of federal oversight and transport-focused regulation.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<center>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/PlantLocations/hysplit-oris-628-january.png" class="lightbox" data-gallery="quarto-lightbox-gallery-4"><img src="Figures/PlantLocations/hysplit-oris-628-january.png" class="img-fluid figure-img" width="848"></a></p>
</figure>
</div>
</div>
</div>
</center>
</div>
</div>
<p><a href="Papers/draft-plant-locations.pdf">Pre-print versions</a></p>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="Papers/draft-gender-bias.pdf">Customer Discrimination in the Workplace: Evidence from Online Sales</a></span></p>
<p><a href="https://www.erinmunrokelley.com">Erin Kelley</a>, <a href="https://www.gregoryvlane.com">Gregory Lane</a>, <a href="http://www.matthewpecenco.com">Matthew Pecenco</a>, and <a href="https://edrub.in">Edward Rubin</a>. Forthcoming. <em>Journal of Labor Economics</em>.</p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>Many workers are evaluated on their ability to engage with customers. This paper measures the impact of gender-based customer discrimination on the productivity of online sales agents working across Sub-Saharan Africa. Using a novel framework that randomly varies the gender of names presented to customers without changing worker behavior, we find that the assignment of a female-sounding name leads to 50 percent fewer purchases by customers. The results appear to be driven by relatively lower interest in engaging with female workers. Since worker productivity informs firm hiring, pay, and promotion decisions, these results are important for understanding the persistence of identity-based discrimination in the labor market.</p>
</div>
</div>
<p><a href="https://www.nber.org/papers/w31998">NBER Working Paper No. 31998</a> | <a href="Papers/draft-gender-bias.pdf">Becker Friedman Institute Working Paper No. 2023-25</a> | <a href="Papers/wp-gender-bias.pdf">World Bank Policy Research Working Paper No. 10228</a> | <a href="Papers/draft-gender-bias.pdf">Draft</a></p>
<p>Coverage: <a href="https://voxdev.org/topic/labour-markets/why-women-africas-services-industry-must-outperform-men-overcome-customer-bias">VoxDev</a> | <a href="https://www.povertyactionlab.org/evaluation/online-customer-discrimination-against-female-workers-sub-saharan-africa">J-PAL</a> | <a href="https://bfi.uchicago.edu/insight/finding/customer-discrimination-in-the-workplace-evidence-from-online-sales/">BFI</a></p>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="Papers/draft-strategic-monitoring.pdf">What’s <em>missing</em> in environmental (self-)monitoring: Evidence from strategic shutdowns of pollution monitors</a></span></p>
<p>Yingfei Mu, <a href="https://edrub.in">Edward Rubin</a>, and <a href="https://www.eric-zou.com">Eric Zou</a> <em>The Review of Economics and Statistics</em>. <a href="https://doi.org/10.1162/rest_a_01477">DOI: 10.1162/rest_a_01477</a></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>Tolerance for gaps in compliance (self-)monitoring data may induce strategic timing in local agents’ monitoring activity. This paper builds a framework to detect whether local governments skip air pollution monitoring when they expect air quality to deteriorate. We infer this expectation from air quality alerts—public advisories based on local governments’ own pollution forecasts—and test whether monitors’ sampling rates fall when these alerts occur. We first use this method to test an individual pollution monitor in Jersey City, NJ, suspected of a deliberate shutdown during the 2013 “Bridgegate” traffic jam. Consistent with strategic shutdowns, this monitor’s sampling rate drops by 33% on pollution-alert days. Building on large-scale inference tools, we then apply the method to test over 1,300 monitors across the U.S., finding 14 metro areas with clusters of monitors showing similar strategic behavior. We discuss imputation methods and policy responses that may help deter future strategic monitoring.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/Intermittent/beta-88101.png" class="lightbox" data-gallery="quarto-lightbox-gallery-5"><img src="Figures/Intermittent/beta-88101.png" class="img-fluid figure-img" style="width:99.0%"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p><a href="https://www.nber.org/papers/w28735">NBER Working Paper No. 28735</a> | <a href="Papers/draft-strategic-monitoring.pdf">Pre-print version</a></p>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="https://www.journals.uchicago.edu/eprint/Q8UYEM4MAQKB6WEDJ8TV/full?redirectUri=/doi/epdf/10.1086/726017">Quantifying heterogeneity in the price elasticity of residential natural gas</a></span></p>
<p><a href="https://edrub.in">Edward Rubin</a> and <a href="https://auffhammer.com">Maximilian Auffhammer</a>. 2024. <em>Journal of the Association of Environmental and Resource Economists</em>, 11(2). <a href="https://www.journals.uchicago.edu/eprint/Q8UYEM4MAQKB6WEDJ8TV/full?redirectUri=/doi/epdf/10.1086/726017">DOI: 10.1086/726017</a></p>
<p>Replication code: <a href="https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/IP6B94">Harvard Dataverse</a></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>We exploit a spatial discontinuity in two natural gas utilities’ service territory—combined with variation in their block-rate pricing structure and a difference in how prima facie determined wholesale prices are deferentially passed though to consumers—to identify average, seasonal, and income-specific own-price elasticities of residential natural gas demand. We estimate an average elasticity ranging from 0.15–0.19 depending on the measure of price used. We further estimate that this elasticity varies substantially across seasons, income groups, and their interaction. We find no significant difference in consumers’ responses to average versus marginal prices.</p>
<!-- Previous titles: *Decomposing "the" elasticity of demand: Empirical and policy insights from 300 million natural gas bills*; *Natural gas price elasticities and optimal cost recovery under consumer heterogeneity: Evidence from 300 million natural gas bills*; *Summertime, and pass-through is easier: Chasing down price elasticities for residential natural* -->
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/NaturalGas/studyMaps.png" class="lightbox" data-gallery="quarto-lightbox-gallery-6"><img src="Figures/NaturalGas/studyMaps.png" class="img-fluid figure-img" width="990"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p><a href="http://www.nber.org/papers/w24295">NBER Working Paper No. 24295</a> | <a href="https://ei.haas.berkeley.edu/research/abstracts/abstract_wp287.html">EI @ Haas Working Paper 287</a></p>
<p>Coverage: <a href="https://www.economist.com/finance-and-economics/2022/08/25/how-to-avoid-energy-rationing">The Economist</a></p>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="https://doi.org/10.3368/le.96.2.188">The economic impact of critical-habitat designation: Evidence from vacant-land transactions</a></span></p>
<p><a href="https://auffhammer.com">Maximilian Auffhammer</a>, <a href="https://oes.gsa.gov/team/maya-duru/">Maya Duru</a>, <a href="https://edrub.in">Edward Rubin</a>, and <a href="https://are.berkeley.edu/users/david-l-sunding">David L. Sunding</a>. 2020. <em>Land Economics</em>, 96(2), 188–206. <a href="https://doi.org/10.3368/le.96.2.188">DOI: 10.3368/le.96.2.188</a></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>The Endangered Species Act (ESA) requires the federal government to designate critical habitat for species listed as threatened or endangered. This provision of the ESA has proven to be one of its most controversial, as critical-habitat land designation entails special management—and potentially greater regulation. In this paper we measure the economic impact of critical-habitat designation by estimating its effect on the market value of vacant land. Using data from over 13,000 vacant-land transactions that occurred within or near critical habitat for two important species in California (red-legged frog and Bay checkerspot butterfly), we show that critical-habitat designation resulted in a large and statistically significant decrease in land value. The estimated impact of critical-habitat designation is heterogeneous: the largest decreases occur within designated urban-growth boundaries.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/CriticalHabitat/rlf_logprice_2006_raw.png" class="lightbox" data-gallery="quarto-lightbox-gallery-7"><img src="Figures/CriticalHabitat/rlf_logprice_2006_raw.png" class="img-fluid figure-img" width="488"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="https://doi.org/10.1257/pandp.20191064">Bringing Satellite-Based Air-Quality Estimates Down to Earth</a></span></p>
<p><a href="https://www.meredithfowlie.com">Meredith Fowlie</a>, <a href="https://edrub.in">Edward Rubin</a>, and <a href="https://w-reed-walker.com">Reed Walker</a>. 2019. “Bringing Satellite-Based Air Quality Estimates Down to Earth.” <em>AEA Papers and Proceedings</em>, 109: 283-88. DOI: [10.1257/pandp.20191064</p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>We use state-of-the-art, satellite-based PM2.5 estimates to assess the extent to which the EPA’s existing, monitor-based measurements over- or under-estimate true exposure to PM2.5 pollution. Treating satellite-based estimates as truth implies a substantial number of “policy errors”—over-regulating areas that comply with air quality standards and under-regulating other areas that appear to violate standards. We investigate the health implications of these apparent errors and highlight the importance of accounting for prediction error in satellite-based estimates. Uncertainty in “policy errors” increases substantially when we account for these underlying prediction errors.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/AirQualityEstimates/box_cbg_di_2003_2007.png" class="lightbox" data-gallery="quarto-lightbox-gallery-8"><img src="Figures/AirQualityEstimates/box_cbg_di_2003_2007.png" class="img-fluid figure-img" width="1275"></a></p>
</figure>
</div>
</div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/AirQualityEstimates/map_di_2005.png" class="lightbox" data-gallery="quarto-lightbox-gallery-9"><img src="Figures/AirQualityEstimates/map_di_2005.png" class="img-fluid figure-img" width="600"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p><a href="https://www.aeaweb.org/articles?id=10.1257/pandp.20191064">Published (P&P) version</a> | <a href="https://www.nber.org/papers/w25560">NBER Working Paper No. 25560</a> | <a href="https://haas.berkeley.edu/wp-content/uploads/WP300.pdf">EI @ Haas Working Paper 300</a></p>
</section>
<section id="books" class="level2">
<h2 class="anchored" data-anchor-id="books">books</h2>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="https://www.springer.com/gp/book/9783030713515">Data Science for Public Policy</a></span></p>
<p><a href="http://jeffchen.org">Jeffrey Chen</a>, Edward Rubin, and <a href="https://garycornwall.weebly.com">Gary Cornwall</a></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>This textbook presents the essential tools and core concepts of data science to public officials, policy analysts, and economists among others in order to further their application in the public sector. An expansion of the quantitative economics frameworks presented in policy and business schools, this book emphasizes the process of asking relevant questions to inform public policy. Its techniques and approaches emphasize data-driven practices, beginning with the basic programming paradigms that occupy the majority of an analyst’s time and advancing to the practical applications of statistical learning and machine learning. The text considers two divergent, competing perspectives to support its applications, incorporating techniques from both causal inference and prediction. Additionally, the book includes open-sourced data as well as live code, written in R and presented in notebook form, which readers can use and modify to practice working with data.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/book-cover.png" class="lightbox" data-gallery="quarto-lightbox-gallery-10"><img src="Figures/book-cover.png" class="img-fluid figure-img" style="width:80.0%"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p>Book links: <a href="https://www.springer.com/gp/book/9783030713515">Springer</a> | <a href="https://www.amazon.com/dp/B09F597WXP/">Amazon</a></p>
</section>
<section id="working-papers" class="level2">
<h2 class="anchored" data-anchor-id="working-papers">working papers</h2>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="Papers/draft-114.pdf">Gun policy and the steel paradox: <em>Evidence from Oregunians</em></a></span></p>
<p><a href="https://www.katiebollman.com/">Katie Bollman</a>, <a href="https://www.benjaminhansen.org/">Benjamin Hansen</a>, <a href="https://edrub.in">Edward Rubin</a>, and <a href="https://www.gstanford.org/">Garrett Stanford</a> <br><em>Revise & resubmit (resubmitted), Journal of Public Economics</em></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>We study the dynamic effects of newly-passed gun legislation on the demand for firearms. We focus on Oregon, where voters affirmed Measure 114 in November of 2022—narrowly passing with 50.7 percent of the vote. In the six weeks following the vote, background checks surged by 400 percent. After a judge’s decision prevented the law from immediate enactment, background checks fell but remained 100 percent higher than pre-legislation levels—even five months after the original vote.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/Oregun/time-series-daily-osp-timeline.png" class="lightbox" data-gallery="quarto-lightbox-gallery-11"><img src="Figures/Oregun/time-series-daily-osp-timeline.png" class="img-fluid figure-img" width="1650"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p><a href="https://www.nber.org/papers/w33360">NBER Working Paper No. 33360</a> | <a href="Papers/draft-114.pdf">Current draft</a></p>
<p>Coverage: <a href="https://www.npr.org/2025/01/28/g-s1-45056/economy-money-papers-explained">NPR</a></p>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="Papers/draft-time.pdf">Does time shift behavior? The clock- vs. solar-time tradeoff</a></span></p>
<p><a href="https://www.patrickbaylis.com">Patrick Baylis</a>, <a href="https://haas.berkeley.edu/faculty/borenstein-severin/">Severin Borenstein</a>, and <a href="https://edrub.in">Edward Rubin</a> <br><em>Revise & resubmit, Journal of Economic Behavior & Organization</em> <br></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>Standardized clock-time is perhaps the most ubiquitous behavioral nudge on the planet. It helps schedule and coordinate economic behavior but also creates tension when it shifts activities away from their locally optimal solar-time. Debates about daylight saving time and areas switching time zones center on this tension. We directly measure the clock- vs. solar-time tradeoff using geolocated data on online behavior (Twitter), commute departures (Census), and foot traffic (SafeGraph). A one-hour change in the wedge between solar-time and clock-time shifts behavior 15–27 minutes, with larger effects in northern latitudes and for activities occurring closer to sunrise.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/Time/sunrise-summer-trim.png" class="lightbox" data-gallery="quarto-lightbox-gallery-12"><img src="Figures/Time/sunrise-summer-trim.png" class="img-fluid figure-img" width="1508"></a></p>
</figure>
</div>
</div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/Time/sunrise-winter-trim.png" class="lightbox" data-gallery="quarto-lightbox-gallery-13"><img src="Figures/Time/sunrise-winter-trim.png" class="img-fluid figure-img" width="1508"></a></p>
</figure>
</div>
</div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/Time/legend-common.png" class="lightbox" data-gallery="quarto-lightbox-gallery-14"><img src="Figures/Time/legend-common.png" class="img-fluid figure-img" width="2580"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p><a href="https://www.nber.org/papers/w30999">NBER Working Paper No. 30999</a> | <a href="Papers/draft-time.pdf">Current draft</a> <br> Blog: <a href="https://energyathaas.wordpress.com/2023/03/06/does-anybody-really-care-what-time-it-is/">Does Anybody Really Care What Time It Is?</a></p>
<p>Coverage: <a href="https://www.nber.org/digest/20235/when-clocks-say-its-one-time-and-sun-says-its-another">NBER Digest</a> | <a href="https://financialpost.com/opinion/william-watson-still-following-the-sun-despite-standardized-time">Financial Post</a></p>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="Papers/draft-smoke.pdf">Who flees wildfire smoke? Income and racial disparities in temporary relocation</a></span></p>
<p><a href="https://edrub.in">Edward Rubin</a> and <a href="https://mstevenholloway.page/home">M. Steven Holloway</a> <br> <em>Submitted</em> <br></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>Individuals can reduce risk exposure through short-term avoidance, but nothing guarantees equal access to this strategy. We quantify inequity in hazard avoidance in the context of wildfire smoke—a widespread, recurrent, and growing health concern that affects millions of people annually. Our analysis links satellite-derived data on wildfire smoke plumes, anonymized cellphone-based movement covering roughly 3 billion visits, and Census Block Group demographics for all urban communities on the US West Coast (2018–2021). We causally estimate how the onset of wildfire smoke affects temporary out-migration-measured as (i) the share of visits occurring outside the home county and (ii) the 75th percentile of distance traveled—and how these responses vary with communities’ income levels and racial/ethnic composition. On average, communities increase their shares of out-of-county travel when wildfire smoke arrives. However, these averages mask stark disparities. Higher-income, less-Black, less-Hispanic, and more-White communities exhibit large and statistically significant smoke-induced increases in out-migration. In contrast, the lowest-income, most-Black, and most-Hispanic communities show no detectable response. Our findings show that even when communities face equal levels of hazardous exposures, their avoidance responses can be highly unequal—potentially compounding existing environmental, health, and social inequities. These results provide important insights for public policy as communities confront increasingly frequent and severe risks from climate and natural disasters.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell quarto-layout-panel" data-layout-ncol="2">
<div class="quarto-layout-row">
<div class="quarto-layout-cell" style="flex-basis: 50.0%;justify-content: center;">
<p><a href="Figures/Smoke/hhinc-q50-subrural0.png" class="lightbox" data-gallery="quarto-lightbox-gallery-15"><img src="Figures/Smoke/hhinc-q50-subrural0.png" class="img-fluid" width="450"></a></p>
</div>
<div class="quarto-layout-cell" style="flex-basis: 50.0%;justify-content: center;">
<p><a href="Figures/Smoke/shrhispanic-q50-subrural0.png" class="lightbox" data-gallery="quarto-lightbox-gallery-16"><img src="Figures/Smoke/shrhispanic-q50-subrural0.png" class="img-fluid" width="450"></a></p>
</div>
</div>
</div>
</div>
</div>
<p><a href="Papers/draft-smoke.pdf">Draft</a></p>
<p><br></p>
<p><span style="font-weight: 900; font-size: 12pt;"><a href="https://doi.org/10.48550/arXiv.2505.13422">Machine learning the first stage in 2SLS: Practical guidance from a bias decomposition and simulation</a></span></p>
<p><a href="https://www.connormlennon.com">Connor Lennon</a>, <a href="https://edrub.in">Edward Rubin</a>, and <a href="http://www.glenwaddell.com">Glen Waddell</a></p>
<div class="grid" style="--bs-columns: 13;">
<div class="g-col-1 g-col-md-1">
</div>
<div class="g-col-12 g-col-md-6">
<p>Machine learning (ML) primarily evolved to solve “prediction problems. The first stage of two-stage least squares (2SLS) is a prediction problem, suggesting potential gains from ML first-stage assistance. However, little guidance exists on when ML helps 2SLS—or when it hurts. We investigate the implications of inserting ML into 2SLS, decomposing the bias into three informative components. Mechanically, ML-in-2SLS procedures face issues common to prediction <em>and</em> causal-inference settings—and their interaction. Through simulation, we show linear ML methods (<em>e.g.</em>, post-Lasso) work well, while nonlinear methods (<em>e.g.</em>, random forests, neural nets) generate substantial bias in second-stage estimates—potentially <em>exceeding</em> the bias of endogenous OLS.</p>
</div>
<div class="g-col-12 g-start-2 g-col-md-6">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/MLIV/sim-density-ridge-t2.png" class="lightbox" data-gallery="quarto-lightbox-gallery-17"><img src="Figures/MLIV/sim-density-ridge-t2.png" class="img-fluid figure-img" width="641"></a></p>
</figure>
</div>
</div>
<div class="cell-output-display">
<div>
<figure class="figure">
<p><a href="Figures/MLIV/sim-exclusion-interaction-3-trees.png" class="lightbox" data-gallery="quarto-lightbox-gallery-18"><img src="Figures/MLIV/sim-exclusion-interaction-3-trees.png" class="img-fluid figure-img" width="664"></a></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p><a href="https://doi.org/10.48550/arXiv.2505.13422">Draft on arXiv</a></p>
</section>
<section id="in-progress" class="level2">
<h2 class="anchored" data-anchor-id="in-progress">in progress</h2>
<p><span style="font-weight: 900; font-size: 12pt;">Declining power-plant emissions, co-benefits, and regulatory rebound</span> <br> <a href="https://www.meredithfowlie.com">Meredith Fowlie</a>, <a href="https://edrub.in">Edward Rubin</a>, and Catherine Wright</p>
<p><span style="font-weight: 900; font-size: 12pt;">Environmental prediction for diverse policy contexts</span> <br> <a href="https://ajdickinson.github.io/">Andrew Dickinson</a> and <a href="https://edrub.in">Edward Rubin</a></p>
<p><span style="font-weight: 900; font-size: 12pt;">Correlated exposures</span> <br> Pilar Mullican and <a href="https://edrub.in">Edward Rubin</a></p>
<p><span style="font-weight: 900; font-size: 12pt;">Mismeasurement in exposure and access: Insights from cellphone data</span></p>
<p><span style="font-weight: 900; font-size: 12pt;">How salient are environmental risks? The short- and long-run effects of lead exposure in piped water</span></p>
<p><span style="font-weight: 900; font-size: 12pt;">Are our hopes too high? Testing cannabis legalization’s potential to reduce criminalization</span></p>
<p><span style="font-weight: 900; font-size: 12pt;">Do aerially applied pesticides affect local air quality? Empirical evidence from California’s San Joaquin Valley</span></p>
</section>
</main> <!-- /main -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const isCodeAnnotation = (el) => {
for (const clz of el.classList) {
if (clz.startsWith('code-annotation-')) {
return true;
}
}
return false;
}
const onCopySuccess = function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
let tooltip;
if (window.bootstrap) {
button.setAttribute("data-bs-toggle", "tooltip");
button.setAttribute("data-bs-placement", "left");
button.setAttribute("data-bs-title", "Copied!");
tooltip = new bootstrap.Tooltip(button,
{ trigger: "manual",
customClass: "code-copy-button-tooltip",
offset: [0, -8]});
tooltip.show();
}
setTimeout(function() {
if (tooltip) {
tooltip.hide();
button.removeAttribute("data-bs-title");
button.removeAttribute("data-bs-toggle");
button.removeAttribute("data-bs-placement");
}
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
}
const getTextToCopy = function(trigger) {
const outerScaffold = trigger.parentElement.cloneNode(true);
const codeEl = outerScaffold.querySelector('code');
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
}
return codeEl.innerText;
}
const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', {
text: getTextToCopy
});
clipboard.on('success', onCopySuccess);
if (window.document.getElementById('quarto-embedded-source-code-modal')) {
const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', {
text: getTextToCopy,
container: window.document.getElementById('quarto-embedded-source-code-modal')
});
clipboardModal.on('success', onCopySuccess);
}
var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
var mailtoRegex = new RegExp(/^mailto:/);
var filterRegex = new RegExp('/' + window.location.host + '/');
var isInternal = (href) => {
return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
}
// Inspect non-navigation links and adorn them if external
var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool):not(.about-link)');
for (var i=0; i<links.length; i++) {
const link = links[i];
if (!isInternal(link.href)) {
// undo the damage that might have been done by quarto-nav.js in the case of
// links that we want to consider external
if (link.dataset.originalHref !== undefined) {
link.href = link.dataset.originalHref;
}
}
}
function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
const config = {
allowHTML: true,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start',
};
if (contentFn) {
config.content = contentFn;
}
if (onTriggerFn) {
config.onTrigger = onTriggerFn;
}
if (onUntriggerFn) {
config.onUntrigger = onUntriggerFn;
}
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
if (note) {
return note.innerHTML;
} else {
return "";
}
});
}
const xrefs = window.document.querySelectorAll('a.quarto-xref');
const processXRef = (id, note) => {
// Strip column container classes
const stripColumnClz = (el) => {
el.classList.remove("page-full", "page-columns");
if (el.children) {
for (const child of el.children) {
stripColumnClz(child);
}
}
}
stripColumnClz(note)
if (id === null || id.startsWith('sec-')) {
// Special case sections, only their first couple elements
const container = document.createElement("div");
if (note.children && note.children.length > 2) {
container.appendChild(note.children[0].cloneNode(true));
for (let i = 1; i < note.children.length; i++) {
const child = note.children[i];
if (child.tagName === "P" && child.innerText === "") {
continue;
} else {
container.appendChild(child.cloneNode(true));
break;
}
}
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(container);
}
return container.innerHTML
} else {
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(note);
}
return note.innerHTML;
}
} else {
// Remove any anchor links if they are present
const anchorLink = note.querySelector('a.anchorjs-link');
if (anchorLink) {
anchorLink.remove();
}
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(note);
}
if (note.classList.contains("callout")) {
return note.outerHTML;
} else {
return note.innerHTML;
}
}
}
for (var i=0; i<xrefs.length; i++) {
const xref = xrefs[i];
tippyHover(xref, undefined, function(instance) {
instance.disable();
let url = xref.getAttribute('href');
let hash = undefined;
if (url.startsWith('#')) {
hash = url;
} else {
try { hash = new URL(url).hash; } catch {}
}
if (hash) {
const id = hash.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
if (note !== null) {
try {
const html = processXRef(id, note.cloneNode(true));
instance.setContent(html);
} finally {
instance.enable();
instance.show();
}
} else {
// See if we can fetch this
fetch(url.split('#')[0])
.then(res => res.text())
.then(html => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, "text/html");
const note = htmlDoc.getElementById(id);
if (note !== null) {
const html = processXRef(id, note);
instance.setContent(html);
}
}).finally(() => {
instance.enable();
instance.show();
});
}
} else {
// See if we can fetch a full url (with no hash to target)
// This is a special case and we should probably do some content thinning / targeting
fetch(url)
.then(res => res.text())
.then(html => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, "text/html");
const note = htmlDoc.querySelector('main.content');
if (note !== null) {
// This should only happen for chapter cross references
// (since there is no id in the URL)
// remove the first header
if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
note.children[0].remove();
}
const html = processXRef(null, note);
instance.setContent(html);
}
}).finally(() => {
instance.enable();
instance.show();
});
}
}, function(instance) {
});
}
let selectedAnnoteEl;
const selectorForAnnotation = ( cell, annotation) => {
let cellAttr = 'data-code-cell="' + cell + '"';
let lineAttr = 'data-code-annotation="' + annotation + '"';
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
return selector;
}
const selectCodeLines = (annoteEl) => {
const doc = window.document;
const targetCell = annoteEl.getAttribute("data-target-cell");
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
const lineIds = lines.map((line) => {
return targetCell + "-" + line;
})
let top = null;
let height = null;
let parent = null;
if (lineIds.length > 0) {
//compute the position of the single el (top and bottom and make a div)
const el = window.document.getElementById(lineIds[0]);
top = el.offsetTop;
height = el.offsetHeight;
parent = el.parentElement.parentElement;
if (lineIds.length > 1) {
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
height = bottom - top;
}
if (top !== null && height !== null && parent !== null) {
// cook up a div (if necessary) and position it
let div = window.document.getElementById("code-annotation-line-highlight");
if (div === null) {
div = window.document.createElement("div");
div.setAttribute("id", "code-annotation-line-highlight");
div.style.position = 'absolute';
parent.appendChild(div);
}
div.style.top = top - 2 + "px";
div.style.height = height + 4 + "px";
div.style.left = 0;
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
if (gutterDiv === null) {
gutterDiv = window.document.createElement("div");
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
gutterDiv.style.position = 'absolute';
const codeCell = window.document.getElementById(targetCell);
const gutter = codeCell.querySelector('.code-annotation-gutter');
gutter.appendChild(gutterDiv);
}
gutterDiv.style.top = top - 2 + "px";
gutterDiv.style.height = height + 4 + "px";
}
selectedAnnoteEl = annoteEl;
}
};
const unselectCodeLines = () => {
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
elementsIds.forEach((elId) => {
const div = window.document.getElementById(elId);
if (div) {
div.remove();
}
});
selectedAnnoteEl = undefined;
};
// Handle positioning of the toggle
window.addEventListener(
"resize",
throttle(() => {
elRect = undefined;
if (selectedAnnoteEl) {
selectCodeLines(selectedAnnoteEl);
}
}, 10)
);
function throttle(fn, ms) {
let throttle = false;
let timer;
return (...args) => {
if(!throttle) { // first call gets through
fn.apply(this, args);
throttle = true;
} else { // all the others get throttled
if(timer) clearTimeout(timer); // cancel #2
timer = setTimeout(() => {
fn.apply(this, args);
timer = throttle = false;
}, ms);
}
};
}
// Attach click handler to the DT
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
for (const annoteDlNode of annoteDls) {
annoteDlNode.addEventListener('click', (event) => {
const clickedEl = event.target;
if (clickedEl !== selectedAnnoteEl) {
unselectCodeLines();
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
if (activeEl) {
activeEl.classList.remove('code-annotation-active');
}
selectCodeLines(clickedEl);
clickedEl.classList.add('code-annotation-active');
} else {
// Unselect the line
unselectCodeLines();
clickedEl.classList.remove('code-annotation-active');
}
});
}
const findCites = (el) => {
const parentEl = el.parentElement;
if (parentEl) {
const cites = parentEl.dataset.cites;
if (cites) {
return {
el,
cites: cites.split(' ')
};
} else {
return findCites(el.parentElement)
}
} else {
return undefined;
}
};
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const citeInfo = findCites(ref);
if (citeInfo) {
tippyHover(citeInfo.el, function() {
var popup = window.document.createElement('div');
citeInfo.cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
}
});
</script>
</div> <!-- /content -->
<script>var lightboxQuarto = GLightbox({"closeEffect":"zoom","descPosition":"bottom","loop":false,"openEffect":"zoom","selector":".lightbox"});
(function() {
let previousOnload = window.onload;
window.onload = () => {
if (previousOnload) {
previousOnload();
}
lightboxQuarto.on('slide_before_load', (data) => {
const { slideIndex, slideNode, slideConfig, player, trigger } = data;
const href = trigger.getAttribute('href');
if (href !== null) {
const imgEl = window.document.querySelector(`a[href="${href}"] img`);
if (imgEl !== null) {
const srcAttr = imgEl.getAttribute("src");
if (srcAttr && srcAttr.startsWith("data:")) {
slideConfig.href = srcAttr;
}
}
}
});
lightboxQuarto.on('slide_after_load', (data) => {
const { slideIndex, slideNode, slideConfig, player, trigger } = data;
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(slideNode);
}
});
};
})();
</script>
</body></html>