forked from flodebarre/covid_vaccination
-
Notifications
You must be signed in to change notification settings - Fork 0
/
annoncesMacron.html
927 lines (797 loc) · 39.3 KB
/
annoncesMacron.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<meta name="author" content="FD" />
<title>Effet des annonces Macron</title>
<script src="annoncesMacron_files/header-attrs-2.7/header-attrs.js"></script>
<script src="annoncesMacron_files/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="annoncesMacron_files/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="annoncesMacron_files/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="annoncesMacron_files/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="annoncesMacron_files/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="annoncesMacron_files/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="annoncesMacron_files/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="annoncesMacron_files/tocify-1.9.1/jquery.tocify.js"></script>
<script src="annoncesMacron_files/navigation-1.1/tabsets.js"></script>
<script src="annoncesMacron_files/navigation-1.1/codefolding.js"></script>
<link href="annoncesMacron_files/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="annoncesMacron_files/highlightjs-9.12.0/highlight.js"></script>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
pre code {
padding: 0;
}
</style>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
<style type="text/css">
.code-folding-btn { margin-bottom: 4px; }
</style>
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
@media print {
.toc-content {
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
float: right;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row">
<div class="col-sm-12 col-md-4 col-lg-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-sm-12 col-md-8 col-lg-9">
<div id="header">
<div class="btn-group pull-right float-right">
<button type="button" class="btn btn-default btn-xs btn-secondary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span>Code</span> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right" style="min-width: 50px;">
<li><a id="rmd-show-all-code" href="#">Show All Code</a></li>
<li><a id="rmd-hide-all-code" href="#">Hide All Code</a></li>
</ul>
</div>
<h1 class="title toc-ignore">Effet des annonces Macron</h1>
<h4 class="author">FD</h4>
</div>
<pre class="r"><code>library(plotly)</code></pre>
<pre><code>## Loading required package: ggplot2</code></pre>
<pre><code>##
## Attaching package: 'plotly'</code></pre>
<pre><code>## The following object is masked from 'package:ggplot2':
##
## last_plot</code></pre>
<pre><code>## The following object is masked from 'package:stats':
##
## filter</code></pre>
<pre><code>## The following object is masked from 'package:graphics':
##
## layout</code></pre>
<pre class="r"><code>library(RColorBrewer)</code></pre>
<div id="initializations" class="section level1">
<h1>Initializations</h1>
<div id="load-data" class="section level2">
<h2>Load data</h2>
<div id="niveau-de-vie-par-epci-2018" class="section level3">
<h3>Niveau de vie par EPCI (2018)</h3>
<p>Source <a href="https://www.insee.fr/fr/statistiques/5009236?sommaire=5009255&q=revenu+epci#dictionnaire" class="uri">https://www.insee.fr/fr/statistiques/5009236?sommaire=5009255&q=revenu+epci#dictionnaire</a></p>
<!--
Code géographique ;
Libellé géographique ;
Nombre de ménages fiscaux ;
Nombre de personnes dans les ménages fiscaux ;
Médiane du niveau de vie (€) ;
Part des ménages fiscaux imposés (%) ;
Taux de pauvreté-Ensemble (%) ;
Taux de pauvreté des ménages dont le référent fiscal a moins de 30 ans (%) ;
Taux de pauvreté des ménages dont le référent fiscal a de 30 à 39 ans (%) ;
Taux de pauvreté des ménages dont le référent fiscal a de 40 à 49 ans (%) ;
Taux de pauvreté des ménages dont le référent fiscal a de 50 à 59 ans (%) ;
Taux de pauvreté des ménages dont le référent fiscal a de 60 à 74 ans (%) ;
Taux de pauvreté des ménages dont le référent fiscal a 75 ans ou plus (%) ;
Taux de pauvreté des ménages propriétaires de leur logement (%) ;
Taux de pauvreté des ménages locataires de leur logement (%) ;
Part des revenus d'activité (%) ;
dont part des salaires, traitements (%) ;
dont part des indemnités de chômage (%) ;
dont part des revenus des activités non salariées (%) ;
Part des pensions, retraites et rentes (%) ;
Part des revenus du patrimoine et des autres revenus (%) ;
Part de l'ensemble des prestations sociales (%) ;
dont part des prestations familiales (%) ;
dont part des minima sociaux (%) ;
dont part des prestations logement (%) ;
Part des impôts (%) ;
Rapport interdécile 9e décile/1er decile ;
1er décile du niveau de vie (€) ;
9e décile du niveau de vie (€).
-->
<pre class="r"><code>dat.revenuEPCI <- read.csv("data/insee/cc_filosofi_2018_EPCI-geo2021.CSV", sep = ";")
head(dat.revenuEPCI)
dat.revenuCom <- read.csv("data/cc_filosofi_2018_COM-geo2021.csv", sep = ";")
head(dat.revenuCom)</code></pre>
</div>
<div id="vaccination-par-epci-et-par-commune" class="section level3">
<h3>Vaccination par EPCI et par commune</h3>
<p>Source <a href="https://datavaccin-covid.ameli.fr/explore/dataset/donnees-de-vaccination-par-epci/download/?format=csv&timezone=Europe/Berlin&lang=fr&use_labels_for_header=true&csv_separator=%3B" class="uri">https://datavaccin-covid.ameli.fr/explore/dataset/donnees-de-vaccination-par-epci/download/?format=csv&timezone=Europe/Berlin&lang=fr&use_labels_for_header=true&csv_separator=%3B</a></p>
<pre class="r"><code>dat.vaccinationEPCI <- read.csv(dataFileEPCI, sep = ";", stringsAsFactors = FALSE, dec = ",")
head(dat.vaccinationEPCI)
dat.vaccinationCom <- read.csv(dataFileCom, sep = ";", stringsAsFactors = FALSE, dec = ",")
head(dat.vaccinationCom)</code></pre>
</div>
<div id="composition-communales" class="section level3">
<h3>Composition communales</h3>
<p>Pour les infos sur les départements</p>
<p>Source <a href="https://www.insee.fr/fr/information/2510634" class="uri">https://www.insee.fr/fr/information/2510634</a></p>
<pre class="r"><code>composition <- read.csv("data/EPCI_composition-communale.csv", encoding = "UFT-8")</code></pre>
<p>Source region codes <a href="https://www.data.gouv.fr/en/datasets/regions-de-france/" class="uri">https://www.data.gouv.fr/en/datasets/regions-de-france/</a></p>
<pre class="r"><code># Departements
departements <- read.csv("data/departement2020.csv")
dic.depname <- departements$libelle
names(dic.depname) <- departements$dep
# Load region codes
reg <- read.csv("data/regions-france.csv")</code></pre>
</div>
</div>
<div id="clean-data" class="section level2">
<h2>Clean data</h2>
<pre class="r"><code># Final week in the data
maxWeek1 <- max(unique(dat.vaccinationEPCI$semaine_injection))
maxWeek2 <- max(unique(dat.vaccinationCom$semaine_injection))
stopifnot(maxWeek1 == maxWeek2)
maxWeek <- maxWeek1</code></pre>
<pre class="r"><code># Weeks in the datasets
wks1 <- sort(unique(dat.vaccinationEPCI$semaine_injection))
wks2 <- sort(unique(dat.vaccinationCom$semaine_injection))
stopifnot(all(wks1 == wks2))
# Check that consecutive weeks
stopifnot(all(is.element(diff(as.numeric(substr(wks1, 6, 7))), c(1, -52))))
wks <- wks1
wks[1] # Show first week; week 52 of 2020 started on 2020-12-21
# Dates of Mondays of the corresponding weeks
beginWeek <- seq(as.Date("2020-12-21"), as.Date("2021-12-31"), by = 7)
names(beginWeek) <- wks
# Dates of Sundays of the corresponding weeks
endWeek <- as.Date(beginWeek) + 6
names(endWeek) <- wks
# Add the day infos to the datasets
dat.vaccinationEPCI$beginWeek <- beginWeek[dat.vaccinationEPCI$semaine_injection]
dat.vaccinationEPCI$endWeek <- endWeek[dat.vaccinationEPCI$semaine_injection]
dat.vaccinationEPCI$week.DD <- paste(dat.vaccinationEPCI$beginWeek, dat.vaccinationEPCI$endWeek, sep = "_")
dat.vaccinationCom$beginWeek <- beginWeek[dat.vaccinationCom$semaine_injection]
dat.vaccinationCom$endWeek <- endWeek[dat.vaccinationCom$semaine_injection]
dat.vaccinationCom$week.DD <- paste(dat.vaccinationCom$beginWeek, dat.vaccinationCom$endWeek, sep = "_")</code></pre>
<p>Merge the vaccination and revenu datasets (all times)</p>
<pre class="r"><code># First, compare contents
## EPCI
# Number of different EPCI in the two datasets
c(vaccin = length(unique(dat.vaccinationEPCI$epci)), revenu = length(unique(dat.revenuEPCI$CODGEO)))
# Compare EPCIs
# Some vaccin are not included in revenu
any(!is.element(unique(dat.vaccinationEPCI$epci), unique(dat.revenuEPCI$CODGEO)))
# All revenu are included in vaccin
any(!is.element(unique(dat.revenuEPCI$CODGEO), unique(dat.vaccinationEPCI$epci)))
## Communes
# Check if vaccination communes included in revenu dataset
any(!is.element(unique(dat.vaccinationCom$commune_residence), unique(dat.revenuCom$CODGEO)))
# Show them -- codes when location is unknown
unique(dat.vaccinationCom$commune_residence)[!is.element(unique(dat.vaccinationCom$commune_residence), unique(dat.revenuCom$CODGEO))]
# Merge the datasets
## EPCI
dat.EPCI <- merge(dat.vaccinationEPCI, dat.revenuEPCI, by.x = "epci", by.y = "CODGEO", all.x = TRUE)
stopifnot(nrow(dat.vaccinationEPCI) == nrow(dat.EPCI)) # Check all included
## Communes
dat.Com <- merge(dat.vaccinationCom, dat.revenuCom, by.x = "commune_residence", by.y = "CODGEO", all.x = TRUE)
stopifnot(nrow(dat.vaccinationCom) == nrow(dat.Com)) # Check all included</code></pre>
<p>Departement information</p>
<pre class="r"><code># Information about departement in which the different EPCI are
# Some are across multiple departements: keep the information by collating them with "_"
agg_nbdep <- aggregate(composition$DEP, by = list(composition$EPCI), FUN = function(i) paste(sort(unique(i)), collapse = "_"))
table(agg_nbdep$x)
# Dictionnary of departement(s) associated to EPCI
dic.dep <- agg_nbdep$x
names(dic.dep) <- agg_nbdep$Group.1
# Add the dep information to our EPCI data
dat.EPCI$dep <- dic.dep[as.character(dat.EPCI$epci)]
# Add the libelle information
dat.EPCI$dep_libelle <- dic.depname[as.character(dat.EPCI$dep)]
# Get departement information in Communes dataset
dat.Com$dep <- substr(dat.Com$commune_residence, 1, 2)</code></pre>
<p>Add region information</p>
<pre class="r"><code># As dictionnary
reg.dic <- c(reg$nom_region)
names(reg.dic) <- reg$code_region # !! Name has to be in quotes
# Initialize region data
unique(dat.EPCI$reg_code)
# Some EPCIs are on two regions
dat.EPCI$twoRegions <- (nchar(dat.EPCI$reg_code) > 2)
# Extract regional code, including for EPCI on two regions
dat.EPCI$reg_code1 <- substr(dat.EPCI$reg_code, 1, 2)
dat.EPCI$reg_code2 <- substr(dat.EPCI$reg_code, 4, 5)
dat.EPCI[which(dat.EPCI$reg_code2 == ""), "reg_code2"] <- NA
dat.EPCI$libelle_region <- reg.dic[dat.EPCI$reg_code1]
dat.EPCI$libelle_region2 <- reg.dic[dat.EPCI$reg_code2]
# Add short names
# Add shorter name
dat.EPCI$reg_shortname <- NA
dat.EPCI[which(dat.EPCI$libelle_region == "Île-de-France"), "reg_shortname"] <- "IDF"
dat.EPCI[which(dat.EPCI$libelle_region == "Provence-Alpes-Côte d'Azur"), "reg_shortname"] <- "PACA"
dat.EPCI[which(dat.EPCI$libelle_region == "Bretagne"), "reg_shortname"] <- "BRE"
dat.EPCI[which(dat.EPCI$libelle_region == "Auvergne-Rhône-Alpes"), "reg_shortname"] <- "ARA"
dat.EPCI[which(dat.EPCI$libelle_region == "Hauts-de-France"), "reg_shortname"] <- "HDF"
dat.EPCI[which(dat.EPCI$libelle_region == "Grand Est"), "reg_shortname"] <- "GE"
dat.EPCI[which(dat.EPCI$libelle_region == "Occitanie"), "reg_shortname"] <- "OCC"
dat.EPCI[which(dat.EPCI$libelle_region == "Normandie"), "reg_shortname"] <- "NOR"
dat.EPCI[which(dat.EPCI$libelle_region == "Bourgogne-Franche-Comté"), "reg_shortname"] <- "BFC"
dat.EPCI[which(dat.EPCI$libelle_region == "Pays de la Loire"), "reg_shortname"] <- "PDL"
dat.EPCI[which(dat.EPCI$libelle_region == "Nouvelle-Aquitaine"), "reg_shortname"] <- "NAQ"
dat.EPCI[which(dat.EPCI$libelle_region == "Centre-Val de Loire"), "reg_shortname"] <- "CVL"
dat.EPCI[which(dat.EPCI$libelle_region == "Corse"), "reg_shortname"] <- "COR"
table(dat.EPCI$reg_shortname, useNA = "ifany")
table(dat.EPCI$libelle_region, useNA = "ifany")
# Missing DOMs
## Coms
unique(dat.Com$dep)
# Initialize region data
dat.Com$reg_shortname <- NA
dat.Com$region <- NA
# Get region from departement information
dat.Com[base::is.element(dat.Com$dep, c("13", "83", "84")), c("reg_shortname", "region")] <- c("PACA", "Provence-Alpes-Côte d'Azur")
dat.Com[base::is.element(dat.Com$dep, c("75", "91", "92", "93", "94", "95")), c("reg_shortname", "region")] <- c("IDF", "Île-de-France")
dat.Com[base::is.element(dat.Com$dep, c("69")), c("reg_shortname", "region")] <- c("ARA", "Auvergne-Rhône-Alpes")</code></pre>
<p>Make sure that values are numeric</p>
<pre class="r"><code>for(col in c("taux_1_inj", "taux_termine",
"taux_cumu_1_inj", "taux_cumu_termine")){
dat.Com[, col] <- as.numeric(dat.Com[, col])
dat.EPCI[, col] <- as.numeric(dat.EPCI[, col])
}</code></pre>
<p>Dictionary of age classes</p>
<pre class="r"><code># Check that age classes match
all(sort(unique(dat.Com$classe_age)) == sort(unique(dat.EPCI$classe_age)))
dic.ages <- as.character(unique(dat.Com$classe_age))
names(dic.ages) <- unique(dat.Com$libelle_classe_age)
dic.ages</code></pre>
</div>
<div id="plot-settings" class="section level2">
<h2>Plot settings</h2>
<p>Region colors and pch</p>
<pre class="r"><code># Define colors, joining palettes
manycols <- c(brewer.pal(name = "Set2", 8), brewer.pal(name = "Set1", 8))
# Region colors
colRegion <- manycols[1:length(unique(dat.EPCI$reg_shortname))]
names(colRegion) <- unique(dat.EPCI$reg_shortname)
# Region pch
pchRegion <- 14 + 1:length(unique(dat.EPCI$reg_shortname))
names(pchRegion) <- names(colRegion)</code></pre>
<p>Age colors</p>
<pre class="r"><code>ages <- unique(dat.EPCI$classe_age)
colAge <- brewer.pal(name = "Dark2", n = length(ages))
names(colAge) <- sort(ages)</code></pre>
</div>
</div>
<div id="some-checks" class="section level1">
<h1>Some checks</h1>
<p>Compare MED18 and PIMP18</p>
<pre class="r"><code>tmp <- dat.EPCI[which(dat.EPCI$classe_age == "TOUT_AGE" & dat.EPCI$semaine_injection == maxWeek), ]
plot(tmp$PIMP18, tmp$MED18, xlab = "PIMP18, Part de ménages fiscaux imposés", ylab = "MED18, revenu médian")</code></pre>
<p><img src="annoncesMacron_files/figure-html/unnamed-chunk-15-1.png" width="672" /></p>
<pre class="r"><code>tmp <- dat.Com[which(dat.Com$classe_age == "TOUT_AGE" & dat.Com$semaine_injection == maxWeek), ]
plot(tmp$PIMP18, tmp$MED18, xlab = "PIMP18, Part de ménages fiscaux imposés", ylab = "MED18, revenu médian")</code></pre>
<p><img src="annoncesMacron_files/figure-html/unnamed-chunk-15-2.png" width="672" /></p>
</div>
<div id="model-and-plot" class="section level1">
<h1>Model and plot</h1>
<div id="final-week-only" class="section level2">
<h2>Final week only</h2>
<div id="all-regions-together-pimp18" class="section level3">
<h3>All regions together, PIMP18</h3>
<pre class="r"><code>mdlFinal.1D.PIMP.0 <- glm(cbind(effectif_1_inj, population_carto - effectif_1_inj) ~ PIMP18 + as.factor(classe_age) + PIMP18 * as.factor(classe_age) + PIMP18 * as.factor(reg_shortname) + as.factor(reg_shortname), family = binomial(link = "logit"), data = dat.EPCI[which(dat.EPCI$classe_age != "TOUT_AGE" & dat.EPCI$semaine_injection == maxWeek), ])
mdlFinal.1D.PIMP.noregion <- glm(cbind(effectif_1_inj, population_carto - effectif_1_inj) ~ PIMP18 + as.factor(classe_age) + PIMP18 * as.factor(classe_age), family = binomial(link = "logit"), data = dat.EPCI[which(dat.EPCI$classe_age != "TOUT_AGE" & dat.EPCI$semaine_injection == maxWeek), ])
mdlComFinal.1D.PIMP.noregion <- glm(cbind(effectif_1_inj, population_carto - effectif_1_inj) ~ PIMP18 + as.factor(classe_age) + PIMP18 * as.factor(classe_age), family = binomial(link = "logit"), data = dat.Com[which(dat.Com$classe_age != "TOUT_AGE" & dat.Com$semaine_injection == maxWeek), ])
mdlFinal.termine.PIMP.noregion <- glm(cbind(effectif_termine, population_carto - effectif_termine) ~ PIMP18 + as.factor(classe_age) + PIMP18 * as.factor(classe_age), family = binomial(link = "logit"), data = dat.EPCI[which(dat.EPCI$classe_age != "TOUT_AGE" & dat.EPCI$semaine_injection == maxWeek), ])
summary(mdlFinal.1D.PIMP.0)</code></pre>
<pre><code>##
## Call:
## glm(formula = cbind(effectif_1_inj, population_carto - effectif_1_inj) ~
## PIMP18 + as.factor(classe_age) + PIMP18 * as.factor(classe_age) +
## PIMP18 * as.factor(reg_shortname) + as.factor(reg_shortname),
## family = binomial(link = "logit"), data = dat.EPCI[which(dat.EPCI$classe_age !=
## "TOUT_AGE" & dat.EPCI$semaine_injection == maxWeek),
## ])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -36.668 -1.365 0.210 1.819 15.218
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.9322108 0.0171742 -170.734 < 2e-16 ***
## PIMP18 -0.0090897 0.0003254 -27.930 < 2e-16 ***
## as.factor(classe_age)20-39 0.7196701 0.0117794 61.096 < 2e-16 ***
## as.factor(classe_age)40-54 0.1970131 0.0129269 15.241 < 2e-16 ***
## as.factor(classe_age)55-64 -0.4767107 0.0167778 -28.413 < 2e-16 ***
## as.factor(classe_age)65-74 -1.2112017 0.0228083 -53.104 < 2e-16 ***
## as.factor(classe_age)75 et + -1.5658759 0.0304622 -51.404 < 2e-16 ***
## as.factor(reg_shortname)BFC -0.0249336 0.0307122 -0.812 0.41688
## as.factor(reg_shortname)BRE 0.1916029 0.0366694 5.225 1.74e-07 ***
## as.factor(reg_shortname)COR 0.5444506 0.1005426 5.415 6.12e-08 ***
## as.factor(reg_shortname)CVL 0.4208589 0.0344427 12.219 < 2e-16 ***
## as.factor(reg_shortname)GE -0.3436633 0.0208999 -16.443 < 2e-16 ***
## as.factor(reg_shortname)HDF -0.2296068 0.0206959 -11.094 < 2e-16 ***
## as.factor(reg_shortname)IDF -0.1202731 0.0260077 -4.625 3.75e-06 ***
## as.factor(reg_shortname)NAQ -0.0126314 0.0227424 -0.555 0.57861
## as.factor(reg_shortname)NOR 0.2155322 0.0345042 6.247 4.20e-10 ***
## as.factor(reg_shortname)OCC 0.1722141 0.0212032 8.122 4.58e-16 ***
## as.factor(reg_shortname)PACA -0.2656015 0.0397303 -6.685 2.31e-11 ***
## as.factor(reg_shortname)PDL -0.1615993 0.0280231 -5.767 8.09e-09 ***
## PIMP18:as.factor(classe_age)20-39 -0.0009883 0.0002249 -4.394 1.11e-05 ***
## PIMP18:as.factor(classe_age)40-54 0.0023599 0.0002471 9.549 < 2e-16 ***
## PIMP18:as.factor(classe_age)55-64 0.0045135 0.0003226 13.991 < 2e-16 ***
## PIMP18:as.factor(classe_age)65-74 0.0054768 0.0004433 12.354 < 2e-16 ***
## PIMP18:as.factor(classe_age)75 et + 0.0017985 0.0005948 3.024 0.00250 **
## PIMP18:as.factor(reg_shortname)BFC 0.0018065 0.0006012 3.005 0.00266 **
## PIMP18:as.factor(reg_shortname)BRE -0.0082465 0.0007330 -11.250 < 2e-16 ***
## PIMP18:as.factor(reg_shortname)COR -0.0153077 0.0020738 -7.381 1.57e-13 ***
## PIMP18:as.factor(reg_shortname)CVL -0.0075276 0.0006735 -11.177 < 2e-16 ***
## PIMP18:as.factor(reg_shortname)GE 0.0078302 0.0004067 19.253 < 2e-16 ***
## PIMP18:as.factor(reg_shortname)HDF 0.0048840 0.0004203 11.619 < 2e-16 ***
## PIMP18:as.factor(reg_shortname)IDF 0.0007386 0.0004380 1.686 0.09175 .
## PIMP18:as.factor(reg_shortname)NAQ -0.0011185 0.0004504 -2.483 0.01302 *
## PIMP18:as.factor(reg_shortname)NOR -0.0037011 0.0006949 -5.326 1.01e-07 ***
## PIMP18:as.factor(reg_shortname)OCC -0.0047290 0.0004280 -11.050 < 2e-16 ***
## PIMP18:as.factor(reg_shortname)PACA 0.0022302 0.0007662 2.911 0.00361 **
## PIMP18:as.factor(reg_shortname)PDL 0.0028417 0.0005576 5.096 3.46e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 698215 on 6959 degrees of freedom
## Residual deviance: 59637 on 6924 degrees of freedom
## (570 observations deleted due to missingness)
## AIC: 105188
##
## Number of Fisher Scoring iterations: 4</code></pre>
<pre class="r"><code>car::Anova(mdlFinal.1D.PIMP.0)</code></pre>
<pre><code>## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(effectif_1_inj, population_carto - effectif_1_inj)
## LR Chisq Df Pr(>Chisq)
## PIMP18 4188 1 < 2.2e-16 ***
## as.factor(classe_age) 621411 5 < 2.2e-16 ***
## as.factor(reg_shortname) 9390 12 < 2.2e-16 ***
## PIMP18:as.factor(classe_age) 624 5 < 2.2e-16 ***
## PIMP18:as.factor(reg_shortname) 1578 12 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<pre class="r"><code>summary(mdlFinal.1D.PIMP.noregion)</code></pre>
<pre><code>##
## Call:
## glm(formula = cbind(effectif_1_inj, population_carto - effectif_1_inj) ~
## PIMP18 + as.factor(classe_age) + PIMP18 * as.factor(classe_age),
## family = binomial(link = "logit"), data = dat.EPCI[which(dat.EPCI$classe_age !=
## "TOUT_AGE" & dat.EPCI$semaine_injection == maxWeek),
## ])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -51.921 -1.210 0.462 2.171 17.007
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -3.1536093 0.0087170 -361.775 < 2e-16 ***
## PIMP18 -0.0057963 0.0001675 -34.611 < 2e-16 ***
## as.factor(classe_age)20-39 0.7720711 0.0107700 71.687 < 2e-16 ***
## as.factor(classe_age)40-54 0.3402482 0.0118503 28.712 < 2e-16 ***
## as.factor(classe_age)55-64 -0.2385210 0.0154022 -15.486 < 2e-16 ***
## as.factor(classe_age)65-74 -0.8008051 0.0211923 -37.788 < 2e-16 ***
## as.factor(classe_age)75 et + -1.1781096 0.0285075 -41.326 < 2e-16 ***
## PIMP18:as.factor(classe_age)20-39 -0.0019813 0.0002064 -9.600 < 2e-16 ***
## PIMP18:as.factor(classe_age)40-54 -0.0002757 0.0002275 -1.211 0.226
## PIMP18:as.factor(classe_age)55-64 0.0001632 0.0002981 0.547 0.584
## PIMP18:as.factor(classe_age)65-74 -0.0020701 0.0004158 -4.979 6.4e-07 ***
## PIMP18:as.factor(classe_age)75 et + -0.0053727 0.0005615 -9.569 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 709834 on 7007 degrees of freedom
## Residual deviance: 87634 on 6996 degrees of freedom
## (522 observations deleted due to missingness)
## AIC: 133519
##
## Number of Fisher Scoring iterations: 4</code></pre>
<pre class="r"><code>car::Anova(mdlFinal.1D.PIMP.noregion)</code></pre>
<pre><code>## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(effectif_1_inj, population_carto - effectif_1_inj)
## LR Chisq Df Pr(>Chisq)
## PIMP18 8063 1 < 2.2e-16 ***
## as.factor(classe_age) 619946 5 < 2.2e-16 ***
## PIMP18:as.factor(classe_age) 221 5 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<pre class="r"><code>summary(mdlComFinal.1D.PIMP.noregion)</code></pre>
<pre><code>##
## Call:
## glm(formula = cbind(effectif_1_inj, population_carto - effectif_1_inj) ~
## PIMP18 + as.factor(classe_age) + PIMP18 * as.factor(classe_age),
## family = binomial(link = "logit"), data = dat.Com[which(dat.Com$classe_age !=
## "TOUT_AGE" & dat.Com$semaine_injection == maxWeek), ])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -13.8472 -1.0524 0.1998 1.3760 8.0121
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -4.4929483 0.0209139 -214.831 < 2e-16 ***
## PIMP18 0.0133969 0.0003418 39.195 < 2e-16 ***
## as.factor(classe_age)20-39 2.0033769 0.0244957 81.785 < 2e-16 ***
## as.factor(classe_age)40-54 2.1790225 0.0262354 83.056 < 2e-16 ***
## as.factor(classe_age)55-64 1.6594954 0.0334634 49.591 < 2e-16 ***
## as.factor(classe_age)65-74 0.9033561 0.0469004 19.261 < 2e-16 ***
## as.factor(classe_age)75 et + 0.3951559 0.0640041 6.174 6.66e-10 ***
## PIMP18:as.factor(classe_age)20-39 -0.0219977 0.0004033 -54.548 < 2e-16 ***
## PIMP18:as.factor(classe_age)40-54 -0.0284901 0.0004356 -65.404 < 2e-16 ***
## PIMP18:as.factor(classe_age)55-64 -0.0277195 0.0005610 -49.407 < 2e-16 ***
## PIMP18:as.factor(classe_age)65-74 -0.0250702 0.0007875 -31.834 < 2e-16 ***
## PIMP18:as.factor(classe_age)75 et + -0.0268261 0.0010699 -25.073 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 78958.6 on 1598 degrees of freedom
## Residual deviance: 7746.8 on 1587 degrees of freedom
## (363 observations deleted due to missingness)
## AIC: 17894
##
## Number of Fisher Scoring iterations: 4</code></pre>
<pre class="r"><code>car::Anova(mdlComFinal.1D.PIMP.noregion)</code></pre>
<pre><code>## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(effectif_1_inj, population_carto - effectif_1_inj)
## LR Chisq Df Pr(>Chisq)
## PIMP18 2642 1 < 2.2e-16 ***
## as.factor(classe_age) 63738 5 < 2.2e-16 ***
## PIMP18:as.factor(classe_age) 5017 5 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<pre class="r"><code>summary(mdlFinal.termine.PIMP.noregion)</code></pre>
<pre><code>##
## Call:
## glm(formula = cbind(effectif_termine, population_carto - effectif_termine) ~
## PIMP18 + as.factor(classe_age) + PIMP18 * as.factor(classe_age),
## family = binomial(link = "logit"), data = dat.EPCI[which(dat.EPCI$classe_age !=
## "TOUT_AGE" & dat.EPCI$semaine_injection == maxWeek),
## ])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -58.586 -1.740 0.257 2.591 41.103
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -3.7595446 0.0100023 -375.870 < 2e-16 ***
## PIMP18 0.0008686 0.0001902 4.566 4.98e-06 ***
## as.factor(classe_age)20-39 0.4742046 0.0124256 38.164 < 2e-16 ***
## as.factor(classe_age)40-54 0.5525441 0.0131508 42.016 < 2e-16 ***
## as.factor(classe_age)55-64 0.4235988 0.0157683 26.864 < 2e-16 ***
## as.factor(classe_age)65-74 0.0662977 0.0201197 3.295 0.000984 ***
## as.factor(classe_age)75 et + -0.5349665 0.0277065 -19.308 < 2e-16 ***
## PIMP18:as.factor(classe_age)20-39 0.0030981 0.0002352 13.170 < 2e-16 ***
## PIMP18:as.factor(classe_age)40-54 -0.0015413 0.0002503 -6.159 7.33e-10 ***
## PIMP18:as.factor(classe_age)55-64 -0.0058286 0.0003035 -19.204 < 2e-16 ***
## PIMP18:as.factor(classe_age)65-74 -0.0099504 0.0003937 -25.274 < 2e-16 ***
## PIMP18:as.factor(classe_age)75 et + -0.0110103 0.0005438 -20.248 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 512981 on 7033 degrees of freedom
## Residual deviance: 158351 on 7022 degrees of freedom
## (496 observations deleted due to missingness)
## AIC: 203816
##
## Number of Fisher Scoring iterations: 4</code></pre>
<pre class="r"><code>car::Anova(mdlFinal.termine.PIMP.noregion)</code></pre>
<pre><code>## Analysis of Deviance Table (Type II tests)
##
## Response: cbind(effectif_termine, population_carto - effectif_termine)
## LR Chisq Df Pr(>Chisq)
## PIMP18 0 1 0.9166
## as.factor(classe_age) 351225 5 <2e-16 ***
## PIMP18:as.factor(classe_age) 2396 5 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
</div>
<div id="france-entiere" class="section level3">
<h3>France entiere</h3>
<div id="une-dose-au-moins-epci" class="section level4">
<h4>Une dose au moins, EPCI</h4>
<pre class="r"><code>par(xpd = TRUE, las = 1)
par(mar = c(4, 4, 4, 4))
par(mgp = c(2, 0.5, 0), tck = -0.01)
tmpAll <- dat.EPCI[which(dat.EPCI$classe_age != "TOUT_AGE" & dat.EPCI$semaine_injection == maxWeek), ]
themaxpop <- max(tmpAll$population_carto)
tmpAll$relsize <- tmpAll$population_carto / themaxpop
tmpAll$relsize.transfo <- 5*(tmpAll$relsize*3)^(1/3)
plot(tmpAll$PIMP18, 100*tmpAll$taux_1_inj,
col = adjustcolor(colAge[tmpAll$classe_age], 0.5),
pch = 16, cex = tmpAll$relsize.transfo,
ylim = c(0, 10), xlim = c(15, 85),
frame.plot = FALSE, yaxs = "i", #xaxs = "i",
xlab = "Part des ménages fiscaux imposés dans l'EPCI en 2018 (%)", ylab = "Taux de vaccination 1 dose au moins (%)",
type = "n"
)
par(xpd = FALSE)
for(i in seq(0, 10, by = 1)){
abline(h = i, col = gray(0.8), lty = 1)
}
legend("topleft", col = colAge[-length(colAge)], legend = names(colAge[-length(colAge)]), pch = 16, bty = "n")
axis(4)
points(tmpAll$PIMP18, 100*tmpAll$taux_1_inj,
col = adjustcolor(colAge[tmpAll$classe_age], 0.5),
pch = 16, cex = tmpAll$relsize.transfo,
)
newdata.noregion <- expand.grid(PIMP18 = seq(min(dat.EPCI$PIMP18, na.rm = TRUE), max(dat.EPCI$PIMP18, na.rm = TRUE), length.out = 100), classe_age = names(colAge[-length(colAge)]))
ndt.noregion <- newdata.noregion
ndt.noregion$prd1D <- predict(mdlFinal.1D.PIMP.noregion, newdata = newdata.noregion, type = "response")
lwd.pred <- 2
for(age in ages[ages!="TOUT_AGE"]){
# Get predicted data for this age class (no region)
subd <- ndt.noregion[ndt.noregion$classe_age == age,]
lines(subd$PIMP18, 100*subd$prd1D, col = colAge[age], lwd = lwd.pred)
}
convertDate <- function(x) format.Date(as.Date(x), "%d/%m")
mtext(side = 3, paste0("France entière\nPendant la semaine du ", convertDate(unique(tmpAll$beginWeek)), " au ", convertDate(unique(tmpAll$endWeek))), line = 1.)</code></pre>
<p><img src="annoncesMacron_files/figure-html/plotFranceEntiereEPCI-1.png" width="672" /></p>
</div>
<div id="une-dose-au-moins-communes" class="section level4">
<h4>Une dose au moins, Communes</h4>
<pre class="r"><code>par(xpd = TRUE, las = 1)
par(mar = c(4, 4, 4, 4))
par(mgp = c(2, 0.5, 0), tck = -0.01)
tmpAll <- dat.Com[which(dat.Com$classe_age != "TOUT_AGE" & dat.Com$semaine_injection == maxWeek), ]
themaxpop <- max(tmpAll$population_carto)
tmpAll$relsize <- tmpAll$population_carto / themaxpop
tmpAll$relsize.transfo <- 2*(tmpAll$relsize*3)^(1/3)
plot(tmpAll$PIMP18, 100*tmpAll$taux_1_inj,
col = adjustcolor(colAge[tmpAll$classe_age], 0.5),
pch = 16, cex = tmpAll$relsize.transfo,
ylim = c(0, 10), xlim = c(15, 85),
frame.plot = FALSE, yaxs = "i", #xaxs = "i",
xlab = "Part des ménages fiscaux imposés dans la commune en 2018 (%)", ylab = "Taux de vaccination 1 dose au moins (%)",
type = "n"
)
par(xpd = FALSE)
for(i in seq(0, 10, by = 1)){
abline(h = i, col = gray(0.8), lty = 1)
}
legend("topleft", col = colAge[-length(colAge)], legend = names(colAge[-length(colAge)]), pch = 16, bty = "n")
axis(4)
points(tmpAll$PIMP18, 100*tmpAll$taux_1_inj,
col = adjustcolor(colAge[tmpAll$classe_age], 0.5),
pch = 16, cex = tmpAll$relsize.transfo,
)
newdata.noregion <- expand.grid(PIMP18 = seq(min(dat.Com$PIMP18, na.rm = TRUE), max(dat.Com$PIMP18, na.rm = TRUE), length.out = 100), classe_age = names(colAge[-length(colAge)]))
ndt.noregion <- newdata.noregion
ndt.noregion$prd1D <- predict(mdlComFinal.1D.PIMP.noregion, newdata = newdata.noregion, type = "response")
lwd.pred <- 2
for(age in ages[ages!="TOUT_AGE"]){
# Get predicted data for this age class (no region)
subd <- ndt.noregion[ndt.noregion$classe_age == age,]
lines(subd$PIMP18, 100*subd$prd1D, col = colAge[age], lwd = lwd.pred)
}
convertDate <- function(x) format.Date(as.Date(x), "%d/%m")
mtext(side = 3, paste0("Communes autour de Paris, Marseille, Lyon\nPendant la semaine du ", convertDate(unique(tmpAll$beginWeek)), " au ", convertDate(unique(tmpAll$endWeek))), line = 1.)</code></pre>
<p><img src="annoncesMacron_files/figure-html/plotFranceEntiereCommunes-1.png" width="672" /></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
<script>
$(document).ready(function () {
window.initializeCodeFolding("hide" === "show");
});
</script>
<script>
$(document).ready(function () {
// move toc-ignore selectors from section div to header
$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "h1,h2,h3",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = true;
options.smoothScroll = true;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>