-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistical_analysis.html
702 lines (626 loc) · 39.5 KB
/
statistical_analysis.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<title>Statistical Analyses</title>
<script src="site_libs/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="site_libs/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<script src="site_libs/htmlwidgets-1.2/htmlwidgets.js"></script>
<script src="site_libs/plotly-binding-4.8.0/plotly.js"></script>
<script src="site_libs/typedarray-0.1/typedarray.min.js"></script>
<link href="site_libs/crosstalk-1.0.0/css/crosstalk.css" rel="stylesheet" />
<script src="site_libs/crosstalk-1.0.0/js/crosstalk.min.js"></script>
<link href="site_libs/plotly-htmlwidgets-css-1.39.2/plotly-htmlwidgets.css" rel="stylesheet" />
<script src="site_libs/plotly-main-1.39.2/plotly-latest.min.js"></script>
<link href="site_libs/font-awesome-5.0.13/css/fa-svg-with-js.css" rel="stylesheet" />
<script src="site_libs/font-awesome-5.0.13/js/fontawesome-all.min.js"></script>
<script src="site_libs/font-awesome-5.0.13/js/fa-v4-shims.min.js"></script>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</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">
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;
}
.table th:not([align]) {
text-align: left;
}
</style>
</head>
<body>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
img {
max-width:100%;
height: auto;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
</style>
<style type="text/css">
/* padding for bootstrap navbar */
body {
padding-top: 51px;
padding-bottom: 40px;
}
/* offset scroll position for anchor links (for fixed navbar) */
.section h1 {
padding-top: 56px;
margin-top: -56px;
}
.section h2 {
padding-top: 56px;
margin-top: -56px;
}
.section h3 {
padding-top: 56px;
margin-top: -56px;
}
.section h4 {
padding-top: 56px;
margin-top: -56px;
}
.section h5 {
padding-top: 56px;
margin-top: -56px;
}
.section h6 {
padding-top: 56px;
margin-top: -56px;
}
</style>
<script>
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark it active
menuAnchor.parent().addClass('active');
// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
});
</script>
<div class="container-fluid main-container">
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
</script>
<!-- code folding -->
<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, '_').toLowerCase();
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = false;
options.smoothScroll = true;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
.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;
padding-left: 25px;
text-indent: 0;
}
.tocify .list-group-item {
border-radius: 0px;
}
.tocify-subheader {
display: inline;
}
.tocify-subheader .tocify-item {
font-size: 0.95em;
}
</style>
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row-fluid">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Home</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="exploratory.html">Exploratory Analyses</a>
</li>
<li>
<a href="flex_dashboard.html">Flex Dashboard</a>
</li>
<li>
<a href="https://aminyakubu.shinyapps.io/NYC_crime_trend/">Shiny App</a>
</li>
<li>
<a href="statistical_analysis.html">Statistical Analysis</a>
</li>
<li>
<a href="acquiringdata.html">The Data</a>
</li>
<li>
<a href="http://github.com/aminyakubu/nyc-crime/">
<span class="fa fa-github fa-lg"></span>
</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div class="fluid-row" id="header">
<h1 class="title toc-ignore">Statistical Analyses</h1>
</div>
<style>
.list-group-item.active, .list-group-item.active:focus, .list-group-item.active:hover {
background-color: #337ab7;
}
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
background-color: #337ab7;
}
.navbar-default {
background-color: #337ab7;
}
.navbar-default .navbar-nav>li>a {
color: white;
font-weight: bold;
}
.navbar-default .navbar-brand {
color: white;
font-weight: bold;
}
</style>
<p><br></p>
<div id="differences-in-length-of-crime" class="section level2">
<h2>Differences in Length of Crime</h2>
<p><br></p>
<div id="introduction" class="section level3">
<h3>Introduction</h3>
<p>In one of the exploratory analyses, we found that the average length of time of the reported crime (i.e., time between when it started and when it ended) differed for each felony type (sex-related, drug-related, and weapons-related). Results from that exploratory analysis are included below. We see that sex-related felonies last an average of 19.236 days, drug-related felonies last an average of 0.586 days, and weapons-related felonies last an average of 0.282 days.</p>
<table>
<thead>
<tr class="header">
<th align="left">Crime group</th>
<th align="right">Count</th>
<th align="right">Average time in days</th>
<th align="right">Standard deviation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">Drug-Related</td>
<td align="right">18293</td>
<td align="right">0.5862466</td>
<td align="right">12.315819</td>
</tr>
<tr class="even">
<td align="left">Sex-Related</td>
<td align="right">8646</td>
<td align="right">19.2362846</td>
<td align="right">83.297645</td>
</tr>
<tr class="odd">
<td align="left">Weapon-Related</td>
<td align="right">19753</td>
<td align="right">0.2820289</td>
<td align="right">9.101974</td>
</tr>
</tbody>
</table>
<p><br></p>
<p>We will assess whether this difference is statistically significant. Testing this difference can yield important insights regarding whether victims are disproportionately suffering the burden of certain crimes, in terms of absolute number of days. Finding a significant result may also suggest that certain felonies are more extensive and complicated, potentially more dangerous or violent, or may require more resources to deal with. Lastly, it may indicate that the victims are at a higher risk compared to those involved in other types of felonies.</p>
<p><br></p>
</div>
<div id="data-and-methods" class="section level3">
<h3>Data and Methods</h3>
<p>We first import the data below and clean up the data. We tidy the data so that Manhattan becomes the reference borough and drug-related felonies become the reference felony. Observations with missing information on when the crime ended where assummed to have the ended the same day it started as NYPD recorded information if only there was an end date.</p>
<p>Since we are testing the difference in means between three groups, we should be able to conduct an ANOVA test. To ensure that the assumptions of the ANOVA test are not violated, we test for homogeneity of variances. We used Levene’s test to test homogeneity of variances. We see from the results below that the p-value is less than 0.05. Therefore, the assumption of homogenous variances is not met.</p>
<table>
<thead>
<tr class="header">
<th align="left">term</th>
<th align="right">df</th>
<th align="right">statistic</th>
<th align="right">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">group</td>
<td align="right">2</td>
<td align="right">903.7685</td>
<td align="right">0</td>
</tr>
<tr class="even">
<td align="left"></td>
<td align="right">46689</td>
<td align="right">NA</td>
<td align="right">NA</td>
</tr>
</tbody>
</table>
<p>We resort to using a non-parametric approach in detecting a difference of means between these three groups by utilizing the Kruskal-Wallis test. Using this test means that we do not make any underlying assumptions about the distribution of the three groups; since these groups potentially come from very different populations, a non-parametric approach seems best for this test.</p>
<table>
<thead>
<tr class="header">
<th align="right">statistic</th>
<th align="right">p.value</th>
<th align="right">parameter</th>
<th align="left">method</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="right">6791.359</td>
<td align="right">0</td>
<td align="right">2</td>
<td align="left">Kruskal-Wallis rank sum test</td>
</tr>
</tbody>
</table>
<p><br></p>
<p>From the test above, it is evident that the p-value is less that 0.05. We conclude that at 5% level of significance, at least one of the average lengths of reported crimes (i.e., time between when the crime started and when it ended) is different among the three felony categories.</p>
<p>Since the Kruskal–Wallis test is significant, we now conduct a post-hoc analysis to determine which crime groups differ from each other level. We use the Dunn test for the post-hoc analysis.</p>
<pre><code>## Comparison Z P.unadj P.adj
## 1 Drug-Related - Sex-Related -75.5637359 0.000000 0.000000
## 2 Drug-Related - Weapon-Related -0.8243442 0.409744 0.409744
## 3 Sex-Related - Weapon-Related 75.8203110 0.000000 0.000000</code></pre>
<p><br></p>
</div>
<div id="results-and-discussion" class="section level3">
<h3>Results and Discussion</h3>
<p>The results show that there is a statistically significant difference between the average length of reported felonies for sex-related and drug-related felonies (p < 0.005), as well as for sex-related and weapons-related felonies (p <0.005). However, there isn’t a significant difference between drug-related and weapons-related felonies (p = 0.4097). All together, we have evidence suggesting that victims of sex-related felonies endure longer incidents, compared to victims of drug-related or weapons-related felonies.</p>
<p>The results of these tests suggest that victims of sex-related felonies endure significantly longer incidents compare to victims of drug-related or weapons-related felonies. This makes sense, considering that sex-related felonies include human trafficking, sexual abuse, and other cases in which the length of the crime is often dragged out compared to those within the other two felonies. Given this result, law enforcement, government, and public health officials should dedicate extra resources to prevent sex-related felonies and ensure that their agencies are adequately prepared and capable to resolve and manage sex-related felonies lasting longer periods of time.</p>
<p><br> <br></p>
</div>
</div>
<div id="association-between-borough-and-crime-occurrence" class="section level2">
<h2>Association Between Borough and Crime Occurrence</h2>
<p><br></p>
<div id="introduction-1" class="section level3">
<h3>Introduction</h3>
<p>In one of our exploratory analyses, we found that felony rates differed by borough (see below).</p>
<<<<<<< HEAD
<div id="htmlwidget-ddd157104b104b5acfb8" style="width:672px;height:480px;" class="plotly html-widget"></div>
<script type="application/json" data-for="htmlwidget-ddd157104b104b5acfb8">{"x":{"data":[{"x":[2014,2015,2016,2017],"y":[0.210786046385165,0.221186002882079,0.238043448707143,0.203308953478887],"text":["year: 2014<br />crime_rate: 0.21078605<br />boro_nm: bronx","year: 2015<br />crime_rate: 0.22118600<br />boro_nm: bronx","year: 2016<br />crime_rate: 0.23804345<br />boro_nm: bronx","year: 2017<br />crime_rate: 0.20330895<br />boro_nm: bronx"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(68,1,84,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(68,1,84,1)"}},"hoveron":"points","name":"bronx","legendgroup":"bronx","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(68,1,84,1)","dash":"solid"},"frame":null},{"x":[2014,2015,2016,2017],"y":[0.136402882695409,0.134326448001734,0.14765338339932,0.148446203918723],"text":["year: 2014<br />crime_rate: 0.13640288<br />boro_nm: brooklyn","year: 2015<br />crime_rate: 0.13432645<br />boro_nm: brooklyn","year: 2016<br />crime_rate: 0.14765338<br />boro_nm: brooklyn","year: 2017<br />crime_rate: 0.14844620<br />boro_nm: brooklyn"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(59,82,139,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(59,82,139,1)"}},"hoveron":"points","name":"brooklyn","legendgroup":"brooklyn","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(59,82,139,1)","dash":"solid"},"frame":null},{"x":[2014,2015,2016,2017],"y":[0.127708627300452,0.140683727722323,0.149333794670237,0.134917016423714],"text":["year: 2014<br />crime_rate: 0.12770863<br />boro_nm: manhattan","year: 2015<br />crime_rate: 0.14068373<br />boro_nm: manhattan","year: 2016<br />crime_rate: 0.14933379<br />boro_nm: manhattan","year: 2017<br />crime_rate: 0.13491702<br />boro_nm: manhattan"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(33,144,140,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(33,144,140,1)"}},"hoveron":"points","name":"manhattan","legendgroup":"manhattan","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(33,144,140,1)","dash":"solid"},"frame":null},{"x":[2014,2015,2016,2017],"y":[0.0875950041168804,0.0857718747959579,0.0876798008294814,0.0779281788803612],"text":["year: 2014<br />crime_rate: 0.08759500<br />boro_nm: queens","year: 2015<br />crime_rate: 0.08577187<br />boro_nm: queens","year: 2016<br />crime_rate: 0.08767980<br />boro_nm: queens","year: 2017<br />crime_rate: 0.07792818<br />boro_nm: queens"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(93,200,99,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(93,200,99,1)"}},"hoveron":"points","name":"queens","legendgroup":"queens","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(93,200,99,1)","dash":"solid"},"frame":null},{"x":[2014,2015,2016,2017],"y":[0.0748762143920844,0.0775876093422156,0.101573026208761,0.0867646384041981],"text":["year: 2014<br />crime_rate: 0.07487621<br />boro_nm: staten_island","year: 2015<br />crime_rate: 0.07758761<br />boro_nm: staten_island","year: 2016<br />crime_rate: 0.10157303<br />boro_nm: staten_island","year: 2017<br />crime_rate: 0.08676464<br />boro_nm: staten_island"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(253,231,37,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(253,231,37,1)"}},"hoveron":"points","name":"staten_island","legendgroup":"staten_island","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(253,231,37,1)","dash":"solid"},"frame":null}],"layout":{"margin":{"t":26.2283105022831,"r":7.30593607305936,"b":40.1826484018265,"l":48.9497716894977},"plot_bgcolor":"rgba(255,255,255,1)","paper_bgcolor":"rgba(255,255,255,1)","font":{"color":"rgba(0,0,0,1)","family":"","size":14.6118721461187},"xaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[2013.85,2017.15],"tickmode":"array","ticktext":["2014","2015","2016","2017"],"tickvals":[2014,2015,2016,2017],"categoryorder":"array","categoryarray":["2014","2015","2016","2017"],"nticks":null,"ticks":"outside","tickcolor":"rgba(51,51,51,1)","ticklen":3.65296803652968,"tickwidth":0.66417600664176,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.689497716895},"tickangle":-0,"showline":true,"linecolor":"rgba(0,0,0,1)","linewidth":0.66417600664176,"showgrid":false,"gridcolor":null,"gridwidth":0,"zeroline":false,"anchor":"y","title":"Year","titlefont":{"color":"rgba(0,0,0,1)","family":"","size":14.6118721461187},"hoverformat":".2f"},"yaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[0.0667178526763315,0.246201810422896],"tickmode":"array","ticktext":["0.10","0.15","0.20"],"tickvals":[0.1,0.15,0.2],"categoryorder":"array","categoryarray":["0.10","0.15","0.20"],"nticks":null,"ticks":"outside","tickcolor":"rgba(51,51,51,1)","ticklen":3.65296803652968,"tickwidth":0.66417600664176,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.689497716895},"tickangle":-0,"showline":true,"linecolor":"rgba(0,0,0,1)","linewidth":0.66417600664176,"showgrid":false,"gridcolor":null,"gridwidth":0,"zeroline":false,"anchor":"x","title":"Felony Rate","titlefont":{"color":"rgba(0,0,0,1)","family":"","size":14.6118721461187},"hoverformat":".2f"},"shapes":[{"type":"rect","fillcolor":null,"line":{"color":null,"width":0,"linetype":[]},"yref":"paper","xref":"paper","x0":0,"x1":1,"y0":0,"y1":1}],"showlegend":true,"legend":{"bgcolor":"rgba(255,255,255,1)","bordercolor":"transparent","borderwidth":1.88976377952756,"font":{"color":"rgba(0,0,0,1)","family":"","size":11.689497716895},"y":0.96751968503937},"annotations":[{"text":"Borough","x":1.02,"y":1,"showarrow":false,"ax":0,"ay":0,"font":{"color":"rgba(0,0,0,1)","family":"","size":14.6118721461187},"xref":"paper","yref":"paper","textangle":-0,"xanchor":"left","yanchor":"bottom","legendTitle":true}],"hovermode":"closest","barmode":"relative"},"config":{"doubleClick":"reset","modeBarButtonsToAdd":[{"name":"Collaborate","icon":{"width":1000,"ascent":500,"descent":-50,"path":"M487 375c7-10 9-23 5-36l-79-259c-3-12-11-23-22-31-11-8-22-12-35-12l-263 0c-15 0-29 5-43 15-13 10-23 23-28 37-5 13-5 25-1 37 0 0 0 3 1 7 1 5 1 8 1 11 0 2 0 4-1 6 0 3-1 5-1 6 1 2 2 4 3 6 1 2 2 4 4 6 2 3 4 5 5 7 5 7 9 16 13 26 4 10 7 19 9 26 0 2 0 5 0 9-1 4-1 6 0 8 0 2 2 5 4 8 3 3 5 5 5 7 4 6 8 15 12 26 4 11 7 19 7 26 1 1 0 4 0 9-1 4-1 7 0 8 1 2 3 5 6 8 4 4 6 6 6 7 4 5 8 13 13 24 4 11 7 20 7 28 1 1 0 4 0 7-1 3-1 6-1 7 0 2 1 4 3 6 1 1 3 4 5 6 2 3 3 5 5 6 1 2 3 5 4 9 2 3 3 7 5 10 1 3 2 6 4 10 2 4 4 7 6 9 2 3 4 5 7 7 3 2 7 3 11 3 3 0 8 0 13-1l0-1c7 2 12 2 14 2l218 0c14 0 25-5 32-16 8-10 10-23 6-37l-79-259c-7-22-13-37-20-43-7-7-19-10-37-10l-248 0c-5 0-9-2-11-5-2-3-2-7 0-12 4-13 18-20 41-20l264 0c5 0 10 2 16 5 5 3 8 6 10 11l85 282c2 5 2 10 2 17 7-3 13-7 17-13z m-304 0c-1-3-1-5 0-7 1-1 3-2 6-2l174 0c2 0 4 1 7 2 2 2 4 4 5 7l6 18c0 3 0 5-1 7-1 1-3 2-6 2l-173 0c-3 0-5-1-8-2-2-2-4-4-4-7z m-24-73c-1-3-1-5 0-7 2-2 3-2 6-2l174 0c2 0 5 0 7 2 3 2 4 4 5 7l6 18c1 2 0 5-1 6-1 2-3 3-5 3l-174 0c-3 0-5-1-7-3-3-1-4-4-5-6z"},"click":"function(gd) { \n // is this being viewed in RStudio?\n if (location.search == '?viewer_pane=1') {\n alert('To learn about plotly for collaboration, visit:\\n https://cpsievert.github.io/plotly_book/plot-ly-for-collaboration.html');\n } else {\n window.open('https://cpsievert.github.io/plotly_book/plot-ly-for-collaboration.html', '_blank');\n }\n }"}],"cloud":false},"source":"A","attrs":{"40cf455c3200":{"x":{},"y":{},"colour":{},"type":"scatter"},"40cf424464beb":{"x":{},"y":{},"colour":{}}},"cur_data":"40cf455c3200","visdat":{"40cf455c3200":["function (y) ","x"],"40cf424464beb":["function (y) ","x"]},"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.2,"selected":{"opacity":1},"debounce":0},"base_url":"https://plot.ly"},"evals":["config.modeBarButtonsToAdd.0.click"],"jsHooks":[]}</script>
=======
<div id="htmlwidget-ed0fa4446400aeb28ddb" style="width:672px;height:480px;" class="plotly html-widget"></div>
<script type="application/json" data-for="htmlwidget-ed0fa4446400aeb28ddb">{"x":{"data":[{"x":[2014,2015,2016,2017],"y":[0.210786046385165,0.221186002882079,0.238043448707143,0.203308953478887],"text":["year: 2014<br />crime_rate: 0.21078605<br />boro_nm: bronx","year: 2015<br />crime_rate: 0.22118600<br />boro_nm: bronx","year: 2016<br />crime_rate: 0.23804345<br />boro_nm: bronx","year: 2017<br />crime_rate: 0.20330895<br />boro_nm: bronx"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(68,1,84,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(68,1,84,1)"}},"hoveron":"points","name":"bronx","legendgroup":"bronx","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(68,1,84,1)","dash":"solid"},"frame":null},{"x":[2014,2015,2016,2017],"y":[0.136402882695409,0.134326448001734,0.14765338339932,0.148446203918723],"text":["year: 2014<br />crime_rate: 0.13640288<br />boro_nm: brooklyn","year: 2015<br />crime_rate: 0.13432645<br />boro_nm: brooklyn","year: 2016<br />crime_rate: 0.14765338<br />boro_nm: brooklyn","year: 2017<br />crime_rate: 0.14844620<br />boro_nm: brooklyn"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(59,82,139,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(59,82,139,1)"}},"hoveron":"points","name":"brooklyn","legendgroup":"brooklyn","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(59,82,139,1)","dash":"solid"},"frame":null},{"x":[2014,2015,2016,2017],"y":[0.127708627300452,0.140683727722323,0.149333794670237,0.134917016423714],"text":["year: 2014<br />crime_rate: 0.12770863<br />boro_nm: manhattan","year: 2015<br />crime_rate: 0.14068373<br />boro_nm: manhattan","year: 2016<br />crime_rate: 0.14933379<br />boro_nm: manhattan","year: 2017<br />crime_rate: 0.13491702<br />boro_nm: manhattan"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(33,144,140,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(33,144,140,1)"}},"hoveron":"points","name":"manhattan","legendgroup":"manhattan","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(33,144,140,1)","dash":"solid"},"frame":null},{"x":[2014,2015,2016,2017],"y":[0.0875950041168804,0.0857718747959579,0.0876798008294814,0.0779281788803612],"text":["year: 2014<br />crime_rate: 0.08759500<br />boro_nm: queens","year: 2015<br />crime_rate: 0.08577187<br />boro_nm: queens","year: 2016<br />crime_rate: 0.08767980<br />boro_nm: queens","year: 2017<br />crime_rate: 0.07792818<br />boro_nm: queens"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(93,200,99,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(93,200,99,1)"}},"hoveron":"points","name":"queens","legendgroup":"queens","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(93,200,99,1)","dash":"solid"},"frame":null},{"x":[2014,2015,2016,2017],"y":[0.0748762143920844,0.0775876093422156,0.101573026208761,0.0867646384041981],"text":["year: 2014<br />crime_rate: 0.07487621<br />boro_nm: staten_island","year: 2015<br />crime_rate: 0.07758761<br />boro_nm: staten_island","year: 2016<br />crime_rate: 0.10157303<br />boro_nm: staten_island","year: 2017<br />crime_rate: 0.08676464<br />boro_nm: staten_island"],"type":"scatter","mode":"markers+lines","marker":{"autocolorscale":false,"color":"rgba(253,231,37,1)","opacity":1,"size":5.66929133858268,"symbol":"circle","line":{"width":1.88976377952756,"color":"rgba(253,231,37,1)"}},"hoveron":"points","name":"staten_island","legendgroup":"staten_island","showlegend":true,"xaxis":"x","yaxis":"y","hoverinfo":"text","line":{"width":3.77952755905512,"color":"rgba(253,231,37,1)","dash":"solid"},"frame":null}],"layout":{"margin":{"t":26.2283105022831,"r":7.30593607305936,"b":40.1826484018265,"l":48.9497716894977},"plot_bgcolor":"rgba(255,255,255,1)","paper_bgcolor":"rgba(255,255,255,1)","font":{"color":"rgba(0,0,0,1)","family":"","size":14.6118721461187},"xaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[2013.85,2017.15],"tickmode":"array","ticktext":["2014","2015","2016","2017"],"tickvals":[2014,2015,2016,2017],"categoryorder":"array","categoryarray":["2014","2015","2016","2017"],"nticks":null,"ticks":"outside","tickcolor":"rgba(51,51,51,1)","ticklen":3.65296803652968,"tickwidth":0.66417600664176,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.689497716895},"tickangle":-0,"showline":true,"linecolor":"rgba(0,0,0,1)","linewidth":0.66417600664176,"showgrid":false,"gridcolor":null,"gridwidth":0,"zeroline":false,"anchor":"y","title":"Year","titlefont":{"color":"rgba(0,0,0,1)","family":"","size":14.6118721461187},"hoverformat":".2f"},"yaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[0.0667178526763315,0.246201810422896],"tickmode":"array","ticktext":["0.10","0.15","0.20"],"tickvals":[0.1,0.15,0.2],"categoryorder":"array","categoryarray":["0.10","0.15","0.20"],"nticks":null,"ticks":"outside","tickcolor":"rgba(51,51,51,1)","ticklen":3.65296803652968,"tickwidth":0.66417600664176,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.689497716895},"tickangle":-0,"showline":true,"linecolor":"rgba(0,0,0,1)","linewidth":0.66417600664176,"showgrid":false,"gridcolor":null,"gridwidth":0,"zeroline":false,"anchor":"x","title":"Felony Rate","titlefont":{"color":"rgba(0,0,0,1)","family":"","size":14.6118721461187},"hoverformat":".2f"},"shapes":[{"type":"rect","fillcolor":null,"line":{"color":null,"width":0,"linetype":[]},"yref":"paper","xref":"paper","x0":0,"x1":1,"y0":0,"y1":1}],"showlegend":true,"legend":{"bgcolor":"rgba(255,255,255,1)","bordercolor":"transparent","borderwidth":1.88976377952756,"font":{"color":"rgba(0,0,0,1)","family":"","size":11.689497716895},"y":0.913385826771654},"annotations":[{"text":"Borough","x":1.02,"y":1,"showarrow":false,"ax":0,"ay":0,"font":{"color":"rgba(0,0,0,1)","family":"","size":14.6118721461187},"xref":"paper","yref":"paper","textangle":-0,"xanchor":"left","yanchor":"bottom","legendTitle":true}],"hovermode":"closest","barmode":"relative"},"config":{"doubleClick":"reset","modeBarButtonsToAdd":[{"name":"Collaborate","icon":{"width":1000,"ascent":500,"descent":-50,"path":"M487 375c7-10 9-23 5-36l-79-259c-3-12-11-23-22-31-11-8-22-12-35-12l-263 0c-15 0-29 5-43 15-13 10-23 23-28 37-5 13-5 25-1 37 0 0 0 3 1 7 1 5 1 8 1 11 0 2 0 4-1 6 0 3-1 5-1 6 1 2 2 4 3 6 1 2 2 4 4 6 2 3 4 5 5 7 5 7 9 16 13 26 4 10 7 19 9 26 0 2 0 5 0 9-1 4-1 6 0 8 0 2 2 5 4 8 3 3 5 5 5 7 4 6 8 15 12 26 4 11 7 19 7 26 1 1 0 4 0 9-1 4-1 7 0 8 1 2 3 5 6 8 4 4 6 6 6 7 4 5 8 13 13 24 4 11 7 20 7 28 1 1 0 4 0 7-1 3-1 6-1 7 0 2 1 4 3 6 1 1 3 4 5 6 2 3 3 5 5 6 1 2 3 5 4 9 2 3 3 7 5 10 1 3 2 6 4 10 2 4 4 7 6 9 2 3 4 5 7 7 3 2 7 3 11 3 3 0 8 0 13-1l0-1c7 2 12 2 14 2l218 0c14 0 25-5 32-16 8-10 10-23 6-37l-79-259c-7-22-13-37-20-43-7-7-19-10-37-10l-248 0c-5 0-9-2-11-5-2-3-2-7 0-12 4-13 18-20 41-20l264 0c5 0 10 2 16 5 5 3 8 6 10 11l85 282c2 5 2 10 2 17 7-3 13-7 17-13z m-304 0c-1-3-1-5 0-7 1-1 3-2 6-2l174 0c2 0 4 1 7 2 2 2 4 4 5 7l6 18c0 3 0 5-1 7-1 1-3 2-6 2l-173 0c-3 0-5-1-8-2-2-2-4-4-4-7z m-24-73c-1-3-1-5 0-7 2-2 3-2 6-2l174 0c2 0 5 0 7 2 3 2 4 4 5 7l6 18c1 2 0 5-1 6-1 2-3 3-5 3l-174 0c-3 0-5-1-7-3-3-1-4-4-5-6z"},"click":"function(gd) { \n // is this being viewed in RStudio?\n if (location.search == '?viewer_pane=1') {\n alert('To learn about plotly for collaboration, visit:\\n https://cpsievert.github.io/plotly_book/plot-ly-for-collaboration.html');\n } else {\n window.open('https://cpsievert.github.io/plotly_book/plot-ly-for-collaboration.html', '_blank');\n }\n }"}],"cloud":false},"source":"A","attrs":{"3e0f65624d16":{"x":{},"y":{},"colour":{},"type":"scatter"},"3e0f18b3135a":{"x":{},"y":{},"colour":{}}},"cur_data":"3e0f65624d16","visdat":{"3e0f65624d16":["function (y) ","x"],"3e0f18b3135a":["function (y) ","x"]},"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.2,"selected":{"opacity":1},"debounce":0},"base_url":"https://plot.ly"},"evals":["config.modeBarButtonsToAdd.0.click"],"jsHooks":[]}</script>
>>>>>>> ad378d97a5a0c24088e7bad4b45b6cebaecf063e
<p><br></p>
<p>Given this result, we decided to formally analyze the association between sex-related, drug-related, and weapons-related felonies and the borough in which the crime occurred; specifically, we looked at whether the occurrence of the felony was higher (or lower) in a particular borough compared to the other boroughs. The importance of examining this association cannot be overstated - determining whether felonies occur more often in a specific borough provides the NYPD and other officials the potential capability of directing their resources toward areas that need them the most.</p>
<p><br></p>
</div>
<div id="data-and-methods-1" class="section level3">
<h3>Data and Methods</h3>
<p><br></p>
<div id="model-statement-for-the-multinomial-logistic-regression-model" class="section level5">
<h5>Model Statement for the Multinomial Logistic Regression Model</h5>
<p>We conducted a multinomial logistic regression to study the association between borough and occurrence of drug-related, sex-related, and weapons-related felonies. The model statement for our research question is included below.</p>
<p><br></p>
<p><span class="math display">\[ln (\frac{P( crimegroup = sex-related)}{P(crime group = drug-related)}) = \beta_{10} + \beta_{11}(Bronx) + \beta_{12}(Brooklyn) + \beta_{13}(Queens) + \beta_{14}(Staten Island)\]</span> <br></p>
<p><span class="math display">\[ln(\frac{P(crimegroup = weapons-related)}{P(crime group = drug-related)}) = \beta_{20} + \beta_{21}(Bronx) + \beta_{22}(Brooklyn) + \beta_{23}(Queens) + \beta_{24}(Staten Island)\]</span></p>
<p><br></p>
<p>Drug-related felonies was chosen as the reference group among the 3 types of felonies because it tends to be the least serious of the 3 crime groups. Among the boroughs, Manhattan was chosen as the reference group because it is widely thought to be the borough with least crime.</p>
<p><br></p>
</div>
<div id="cross-tabulation" class="section level4">
<h4>Cross tabulation</h4>
<p>We created a data table to organize the rates of drug-related, sex-related, and weapons-related felonies; we stratified the results by borough. From the table, we can see that, in terms of absolute numbers, Brooklyn has the highest incidence of weapons-related and sex-related felonies, while the Bronx has the highest incidence of drug-related felonies.</p>
<table>
<thead>
<tr class="header">
<th></th>
<th align="right">Drug-Related</th>
<th align="right">Sex-Related</th>
<th align="right">Weapon-Related</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>manhattan</td>
<td align="right">3566</td>
<td align="right">2084</td>
<td align="right">3550</td>
</tr>
<tr class="even">
<td>bronx</td>
<td align="right">6312</td>
<td align="right">1980</td>
<td align="right">4556</td>
</tr>
<tr class="odd">
<td>brooklyn</td>
<td align="right">5144</td>
<td align="right">2592</td>
<td align="right">7278</td>
</tr>
<tr class="even">
<td>queens</td>
<td align="right">2589</td>
<td align="right">1693</td>
<td align="right">3713</td>
</tr>
<tr class="odd">
<td>staten_island</td>
<td align="right">682</td>
<td align="right">297</td>
<td align="right">655</td>
</tr>
</tbody>
</table>
<p><br></p>
<p>Next, we fit a logistic regression model to the data. We also plot the data into a graph.</p>
<table>
<thead>
<tr class="header">
<th align="left">Crime group</th>
<th align="left">Term</th>
<th align="right">Estimate</th>
<th align="right">Standard error</th>
<th align="right">statistic</th>
<th align="right">P value</th>
<th align="right">Odds Ratio</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">Sex-Related</td>
<td align="left">Intercept</td>
<td align="right">0.5844049</td>
<td align="right">0.0275731</td>
<td align="right">-19.4813700</td>
<td align="right">0.0000000</td>
<td align="right">1.793923</td>
</tr>
<tr class="even">
<td align="left">Sex-Related</td>
<td align="left">Bronx</td>
<td align="right">0.5367635</td>
<td align="right">0.0377326</td>
<td align="right">-16.4896410</td>
<td align="right">0.0000000</td>
<td align="right">1.710462</td>
</tr>
<tr class="odd">
<td align="left">Sex-Related</td>
<td align="left">Brooklyn</td>
<td align="right">0.8622320</td>
<td align="right">0.0366125</td>
<td align="right">-4.0486419</td>
<td align="right">0.0000515</td>
<td align="right">2.368441</td>
</tr>
<tr class="even">
<td align="left">Sex-Related</td>
<td align="left">Queens</td>
<td align="right">1.1189544</td>
<td align="right">0.0416796</td>
<td align="right">2.6966344</td>
<td align="right">0.0070044</td>
<td align="right">3.061651</td>
</tr>
<tr class="odd">
<td align="left">Sex-Related</td>
<td align="left">Staten island</td>
<td align="right">0.7451797</td>
<td align="right">0.0747898</td>
<td align="right">-3.9327525</td>
<td align="right">0.0000840</td>
<td align="right">2.106820</td>
</tr>
<tr class="even">
<td align="left">Weapon-Related</td>
<td align="left">Intercept</td>
<td align="right">0.9955120</td>
<td align="right">0.0237090</td>
<td align="right">-0.1897204</td>
<td align="right">0.8495282</td>
<td align="right">2.706110</td>
</tr>
<tr class="odd">
<td align="left">Weapon-Related</td>
<td align="left">Bronx</td>
<td align="right">0.7250480</td>
<td align="right">0.0306600</td>
<td align="right">-10.4865465</td>
<td align="right">0.0000000</td>
<td align="right">2.064830</td>
</tr>
<tr class="even">
<td align="left">Weapon-Related</td>
<td align="left">Brooklyn</td>
<td align="right">1.4212297</td>
<td align="right">0.0298985</td>
<td align="right">11.7572104</td>
<td align="right">0.0000000</td>
<td align="right">4.142211</td>
</tr>
<tr class="odd">
<td align="left">Weapon-Related</td>
<td align="left">Queens</td>
<td align="right">1.4406084</td>
<td align="right">0.0348954</td>
<td align="right">10.4617057</td>
<td align="right">0.0000000</td>
<td align="right">4.223264</td>
</tr>
<tr class="even">
<td align="left">Weapon-Related</td>
<td align="left">Staten island</td>
<td align="right">0.9647314</td>
<td align="right">0.0596248</td>
<td align="right">-0.6021913</td>
<td align="right">0.5470468</td>
<td align="right">2.624083</td>
</tr>
</tbody>
</table>
<p><img src="statistical_analysis_files/figure-html/graph_felony_and_boroughs-1.png" width="672" /></p>
<p><br></p>
</div>
</div>
<div id="results-and-discussion-1" class="section level3">
<h3>Results and Discussion</h3>
<p>From the data table and the graph above, we see that:</p>
<ul>
<li>The odds of a sex-related felony occurring in Manhattan is 1.79 times the odds of a drug-related felony occurring in Manhattan.</li>
<li>The odds of a sex-related felony occurring in the Bronx is 1.71 times the odds of a drug-related felony occurring in Manhattan.</li>
<li>The odds of a sex-related felony occurring in Brooklyn is 2.37 times the odds of a drug-related felony occurring in Manhattan.</li>
<li>The odds of a sex-related felony occurring in Queens is 3.06 times the odds of a drug-related felony occurring in Manhattan.</li>
<li>The odds of a sex-related felony occurring in Staten Island is 2.11 times the odds of a drug-related felony occurring in Manhattan.</li>
</ul>
<p><br></p>
<ul>
<li>The odds of a weapons-related felony occurring in Manhattan is 2.71 times the odds of a drug-related felony occuring in Manhattan.</li>
<li>The odds of a weapons-related felony occurring in the Bronx is 2.06 times the odds of a drug-related felony occurring in Manhattan.</li>
<li>The odds of a weapons-related felony occurring in Brooklyn is 4.14 times the odds of a drug-related felony occurring in Manhattan.</li>
<li>The odds of a weapons-related felony occurring in Queens is 4.22 times the odds of a drug-related felony occurring in Manhattan.</li>
<li>The odds of a weapons-related felony occurring in Staten Island is 2.62 times the odds of a drug-related felony occurring in Manhattan.</li>
</ul>
<p>These results suggest a significantly higher odds of a sex-related or a weapons-related felony occurring in all 4 boroughs compared to a drug-related felony occurring in Manhattan. Of note is that a weapons-related felony (OR = 4.22) and a sex-related felony (OR = 3.06) is more likely to occur in Queens compared to a drug-related felony in Manhattan - these odds represent the highest among the boroughs.</p>
</div>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</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>