-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnh_charge_type_analysis.Rmd
More file actions
2602 lines (2251 loc) · 135 KB
/
nh_charge_type_analysis.Rmd
File metadata and controls
2602 lines (2251 loc) · 135 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
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Charge Analysis"
output:
distill::distill_article:
toc: true
toc_depth: 3
self_contained: false
---
**Counties Included**: All New Hampshire counties except Grafton and Strafford. Strafford is excluded because their data does not include any charge information (neither charge code nor charge description).
The following analysis uses jail administrative data submitted directly to CSG in addition to a NH offense look-up table with offense codes, descriptions, and degrees (e.g., Class A Misdemeanor, etc.). However, we will not be able to analyze severity/degree of charges with the data we've received. With only offense statute and description, we can’t accurately tell if a given charge is a misdemeanor or felony (or even class A misdemeanor versus class B misdemeanor). For this level of detail, we would need either the ‘Smart Code’ or the ‘ODDSY Code’ – which may not even be known at the time of booking. For instance, there are 8 entries for ‘criminal trespass’/’statute ‘635:2’ in the look-up file – which degrees ranging from violations to class A and B misdemeanors to class B felonies.
It appears that the best option, at this point, is to categorize the charges into violent, public order, drugs/alcohol, property, and probation/parole violation. Drawing from approaches used by the NH Department of Safety (see https://crimestats.dos.nh.gov/public/Dim/dimension.aspx) as well as FBI definitions for both NIBRS and UCR data (see https://www.waspc.org/assets/CJIS/trainingmanualsandreference/nibrsvssummaryoverview.pdf), I categorized certain offenses into these categories. For full list of which offenses are grouped into each crime type, see table below.
**Business Rules**: When cleaning the charge data, I first de-duplicated by individual (id + inmate_id), booking (booking_id), and charge (either charge_code or charge_desc depending on data availability). There appear to be some duplicates across these fields, but we have no way of knowing if two identical charges for the same booking represents a duplicated entry or multiple counts of the same charge. Unfortunately, this will likely just be a limitation of this analysis. After joining the jail charge data to the updated look-up table with crime type data, I de-duplicated the file again by individual and booking -- keeping the most serious charge type. Here is the crime type hierarchy (in order of severity) I used for this decision: violent, property, drug/alcohol, public order, violation of probation/parole, Failure to Appear/Bail, Temporary Hold, and then other/missing categories. One limitation is that we are not able to account for degree/severity of charge (felony vs. misdemeanor) with this approach.
**Remaining Questions for Superintendents**:
* There is missing charge code/charge description data across most counties. How should we interpret this? Belknap seems to have the highest rates of missingness with about 11% of non-PC hold booking have no charge code or charge description. In general, how should we interpret missing charge data? Why is it missing? Is it missing at random?
* Is there consistency in when/how charges are entered as probation or parole violations? If there is not an additional charge linked to the booking, does this likely indicate a technical violation? Or does it vary by county?
<br>
```{r include=FALSE}
### call libraries
library(easypackages)
libraries("tidyverse","foreign","lubridate","reshape2", "ggplot2","RColorBrewer","knitr","forcats","openxlsx","statar","svDialogs","xlsx", "magrittr","stringr", "data.table","janitor","kableExtra","leaflet", "readr", "rmarkdown","rowr", "gganimate", "gifski","tidycensus","sf","htmltools","acs","tigris","mapview","rgeos", "ggrepel", "censusxy","gdata","lavaan","mclust","tmap","scales", "raster","rgeos","gmapsdistance","viridis","cowplot","lintr","leaflet.extras","censusapi","data.table","gridGraphics","readxl","haven","ggridges","extrafont","extrafontdb","datamodelr","Lahman","DiagrammeR","fs","readxl","rsvg","V8","ragg","ggtext","csgjcr","distill","gtsummary")
# Load functions, packages, and data
source("code/00_library.R")
source("code/01_functions.R")
source("code/rdas.R")
```
```{r setup, include=FALSE}
### set chunk output
knitr::opts_chunk$set(
echo = TRUE,
dev = "ragg_png",
cache = FALSE
)
### import cleaned charge analytic file (for all eight counties with charge data)
load(paste0(sp_data_path, "/Data/analysis/r_data/offenses_clean/nh_eight_county_charge_clean_final.Rda", sep = ""))
### import and clean raw charge codes look-up table
charge_codes_crime_type_lookup_for_table <- read_excel(paste0(sp_data_path, "/Data/Offense Information/CPI_DMV_COURT_crime_type_clean.xls"),
sheet = "charge_lookup_crime_type_full") %>%
clean_names() %>%
mutate(descriptor_lookup = str_to_title(descriptor),
statute_title_lookup = str_to_title(statute_title),
charge_code_lookup = str_to_title(offense_statute)) %>%
### Based on the jail charge data we've received, I don't think we can look at severity/degree of charges
### With only offense statute and description, we can't accurately tell if a given charge is a misdemeanor or felony (or even class A misdemeanor versus class B misdemeanor)
### For this level of detail, we'd need either the 'Smart Code' or the 'ODDSY Code' - which may not even be known at the time of booking
### For instance, there are 8 entries for 'criminal trespass'/'statute '635:2' in the lookup file - which degrees ranging from violations to class A and B misdemeanors to class B felonies
### I think the best option, at this point, is to just categorize the charges into violent, public order, drugs/alcohol, property, FTA/Bail, temporary hold
distinct(statute_title_lookup,
crime_type,
.keep_all = TRUE) %>% ### de-dup by offense information and crime type
dplyr::select(charge_code_lookup,
descriptor_lookup,
statute_title_lookup,
crime_type_lookup=crime_type)
```
# Raw Charges and Coded Charge Type
Here is a list of all charges that were categorized as either violent, property, drug/alcohol, public order, failure to appear, temporary hold, or probation/parole violations. These are not necessarily charges associated with jail bookings or individuals in the jail data files.
Note: The charge descriptions still need to be cleaned/standardized in some cases (e.g., "Willful Concealment" and "Willful Concealment and Shoplifting")
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create table of unique statute titles and associated crime/charge type (only for charges with crime type value)
table_charge_codes_crime_type_lookup <- charge_codes_crime_type_lookup_for_table %>%
filter(!is.na(crime_type_lookup)) %>%
dplyr::group_by(statute_title_lookup,
crime_type_lookup) %>%
dplyr::summarise(`Unique Descriptions (N)` = n_distinct(descriptor_lookup)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = statute_title_lookup,
`Charge Type` = crime_type_lookup) %>%
dplyr::select(-`Unique Descriptions (N)`)
### print table via kableextra
kable(table_charge_codes_crime_type_lookup,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l")
```
<br><br>
# Bookings by Charge Type (most serious) across New Hampshire
Note: I am considering a booking to be 'unique' if the following values are together unique: id, inmate_id, booking_id, county (including county as we can't verify that each county is using different IDs for individuals and bookings). The count reported in the following tables is the unique number of bookings for which the most serious charge type is a violent charge, property charge, etc.
```{r include=FALSE,message=FALSE,warning=FALSE}
nh_eight_county_charge_clean_final_id <- nh_eight_county_charge_clean_final %>%
mutate(unique_booking_id_nh = paste0(id,
inmate_id,
booking_id,
county)) %>%
mutate(descriptor_lookup = str_to_title(descriptor_lookup),
statute_title_lookup = str_to_title(statute_title_lookup)) ### clean up descriptor and statute title for tables
```
<br>
### Most Common Charges across Charge Type, Statewide (top 20)
Note: This table excludes non-PC holds as well as charges that were not categorized into a specific charge type. The charge descriptions still need to be cleaned/standardized in some cases (e.g., "Willful Concealment" and "Willful Concealment and Shoplifting").
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample excluding pc-holds
unique_bookings_all_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$pc_hold=="Non-PC Hold" & nh_eight_county_charge_clean_final_id$statute_title_lookup!="Missing"])
### unique bookings per charge description
df_nh_all_offense_desc_count <- nh_eight_county_charge_clean_final_id %>%
filter(pc_hold=="Non-PC Hold",
statute_title_lookup!="Missing") %>%
dplyr::group_by(statute_title_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_all_denom,
accuracy = .1)) %>%
ungroup() %>%
arrange(desc(`Unique Bookings (N)`)) %>%
head(20) %>%
dplyr::rename(`Charge Description` = statute_title_lookup)
### print table via kableextra
kable(df_nh_all_offense_desc_count,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l")
```
<br>
### Violent Offenses, Statewide
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample
unique_bookings_violent_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$crime_type_lookup=="Violent"])
### unique bookings per charge description
df_nh_violent_offense_desc_count <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Violent") %>%
dplyr::group_by(statute_title_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_violent_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = statute_title_lookup)
### overall
df_nh_violent_offense_count_overall <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Violent") %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_violent_denom,
accuracy = .1)) %>%
mutate(`Charge Description` = "Overall")
### combine tables for kable
table_nh_violent_offense_desc_count_final <- rbind(df_nh_violent_offense_desc_count,
df_nh_violent_offense_count_overall)
### print table via kableextra
kable(table_nh_violent_offense_desc_count_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(28, bold = TRUE)
```
<br>
### Property Offenses, Statewide
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample
unique_bookings_property_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$crime_type_lookup=="Property"])
### unique bookings per charge description
df_nh_property_offense_desc_count <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Property") %>%
dplyr::group_by(statute_title_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_property_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = statute_title_lookup)
### overall
df_nh_property_offense_count_overall <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Property") %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_property_denom,
accuracy = .1)) %>%
mutate(`Charge Description` = "Overall")
### combine tables for kable
table_nh_property_offense_desc_count_final <- rbind(df_nh_property_offense_desc_count,
df_nh_property_offense_count_overall)
### print table via kableextra
kable(table_nh_property_offense_desc_count_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(28, bold = TRUE)
```
<br>
### Drug/Alcohol Offenses, Statewide
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample
unique_bookings_drug_alc_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$crime_type_lookup=="Drug/Alcohol"])
### unique bookings per charge description
df_nh_drug_alc_offense_desc_count <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Drug/Alcohol") %>%
dplyr::group_by(statute_title_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_drug_alc_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = statute_title_lookup)
### overall
df_nh_drug_alc_offense_count_overall <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Drug/Alcohol") %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_drug_alc_denom,
accuracy = .1)) %>%
mutate(`Charge Description` = "Overall")
### combine tables for kable
table_nh_drug_alc_offense_desc_count_final <- rbind(df_nh_drug_alc_offense_desc_count,
df_nh_drug_alc_offense_count_overall)
### print table via kableextra
kable(table_nh_drug_alc_offense_desc_count_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(13, bold = TRUE)
```
<br>
### Drug/Alcohol Offenses, Statewide
Note: This table is broken down further as the broader categories above don't say much for drug/alcohol charges
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample
unique_bookings_drug_alc_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$crime_type_lookup=="Drug/Alcohol"])
### unique bookings per charge description
df_nh_drug_alc_offense_desc_count_2 <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Drug/Alcohol") %>%
dplyr::group_by(descriptor_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_drug_alc_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description (Detailed)` = descriptor_lookup)
### overall
df_nh_drug_alc_offense_count_overall_2 <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Drug/Alcohol") %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_drug_alc_denom,
accuracy = .1)) %>%
mutate(`Charge Description (Detailed)` = "Overall")
### combine tables for kable
table_nh_drug_alc_offense_desc_count_final_2 <- rbind(df_nh_drug_alc_offense_desc_count_2,
df_nh_drug_alc_offense_count_overall_2)
### print table via kableextra
kable(table_nh_drug_alc_offense_desc_count_final_2,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(57, bold = TRUE)
```
<br>
### Public Order Offenses, Statewide
Note: 'Transporting Alcoholic Beverages' appears to be the same as 'Open Container'
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample
unique_bookings_public_order_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$crime_type_lookup=="Public Order"])
### unique bookings per charge description
df_nh_public_order_offense_desc_count <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Public Order") %>%
dplyr::group_by(statute_title_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_public_order_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = statute_title_lookup)
### overall
df_nh_public_order_offense_count_overall <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Public Order") %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_public_order_denom,
accuracy = .1)) %>%
mutate(`Charge Description` = "Overall")
### combine tables for kable
table_nh_public_order_offense_desc_count_final <- rbind(df_nh_public_order_offense_desc_count,
df_nh_public_order_offense_count_overall)
### print table via kableextra
kable(table_nh_public_order_offense_desc_count_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(15, bold = TRUE)
```
<br>
### Probation/Parole Violations, Statewide
Note: If charge description is missing, charge code or charge statute name was utlized for coding
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample
unique_bookings_vop_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$crime_type_lookup=="Probation/Parole Violation"])
### unique bookings per charge description
df_nh_vop_offense_desc_count <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Probation/Parole Violation") %>%
dplyr::group_by(descriptor_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_vop_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = descriptor_lookup)
### overall
df_nh_vop_offense_count_overall <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Probation/Parole Violation") %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_vop_denom,
accuracy = .1)) %>%
mutate(`Charge Description` = "Overall")
### combine tables for kable
table_nh_vop_offense_desc_count_final <- rbind(df_nh_vop_offense_desc_count,
df_nh_vop_offense_count_overall)
### print table via kableextra
kable(table_nh_vop_offense_desc_count_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(14, bold = TRUE)
```
<br>
### Failure to Appear/Bail, Statewide
Note: If charge description is missing, charge code or charge statute name was utilized for coding
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample
unique_bookings_fta_bail_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$crime_type_lookup=="FTA/Bail"])
### unique bookings per charge description
df_nh_fta_bail_offense_desc_count <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="FTA/Bail") %>%
dplyr::group_by(descriptor_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_vop_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = descriptor_lookup)
### overall
df_nh_fta_bail_offense_count_overall <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="FTA/Bail") %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_vop_denom,
accuracy = .1)) %>%
mutate(`Charge Description` = "Overall")
### combine tables for kable
table_nh_fta_bail_offense_desc_count_final <- rbind(df_nh_fta_bail_offense_desc_count,
df_nh_fta_bail_offense_count_overall)
### print table via kableextra
kable(table_nh_fta_bail_offense_desc_count_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(13, bold = TRUE)
```
<br>
### Temporary Hold, Statewide
Note: If charge description is missing, charge code or charge statute name was utilized for coding
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominator -- unique bookings for sub-sample
unique_bookings_temp_hold_bail_denom <- n_distinct(nh_eight_county_charge_clean_final_id$unique_booking_id_nh[nh_eight_county_charge_clean_final_id$crime_type_lookup=="Temporary Hold"])
### unique bookings per charge description
df_nh_temp_hold_offense_desc_count <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Temporary Hold") %>%
dplyr::group_by(descriptor_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_vop_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = descriptor_lookup)
### overall
df_nh_temp_hold_offense_count_overall <- nh_eight_county_charge_clean_final_id %>%
filter(crime_type_lookup=="Temporary Hold") %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_vop_denom,
accuracy = .1)) %>%
mutate(`Charge Description` = "Overall")
### combine tables for kable
table_nh_temp_hold_offense_desc_count_final <- rbind(df_nh_temp_hold_offense_desc_count,
df_nh_temp_hold_offense_count_overall)
### print table via kableextra
kable(table_nh_temp_hold_offense_desc_count_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(13, bold = TRUE)
```
<br>
### Other/Uncoded Charges, Statewide (20 most common charges)
Note: These are charges that were not grouped into either violent, property, drug/alcohol, public order, FTA/bail, temporary hold, or probation/parole violation categories based on the resources we used as guides. We may want to group additional charges into one of these categories, though. Values of "NA" indicate the charge data provided by jails was missing.
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create df without pc holds and recode missing charge types as other (for now)
nh_eight_county_charge_clean_final_crime_type_recode_non_pc <- nh_eight_county_charge_clean_final_id %>%
filter(pc_hold=="Non-PC Hold") %>%
mutate(crime_type_clean = ifelse(is.na(crime_type_lookup)==TRUE,
"Other",
crime_type_lookup))
### create denominator -- unique bookings for sub-sample
unique_bookings_other_denom <- n_distinct(nh_eight_county_charge_clean_final_crime_type_recode_non_pc$unique_booking_id_nh[nh_eight_county_charge_clean_final_crime_type_recode_non_pc$crime_type_clean=="Other"])
### unique bookings per charge description
df_nh_other_offense_desc_count_top_20 <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
filter(crime_type_clean=="Other") %>%
dplyr::group_by(descriptor_lookup) %>%
dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_other_denom,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description (Detailed)` = descriptor_lookup) %>%
arrange(desc(`Unique Bookings (N)`)) %>%
head(20) ### take top 20
### write out all offenses with 'other' flag to excel for review by policy team
# ### unique bookings per charge description
# df_nh_other_offense_desc_count_raw <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
# filter(crime_type_clean=="Other") %>%
# dplyr::group_by(descriptor_lookup) %>%
# dplyr::summarise(`Unique Bookings (N)` = n_distinct(unique_booking_id_nh),
# `Bookings, Percent of Sample (%)` = scales::percent(`Unique Bookings (N)`/unique_bookings_other_denom,
# accuracy = .1)) %>%
# ungroup() %>%
# dplyr::rename(`Charge Description (Detailed)` = descriptor_lookup) %>%
# arrange(desc(`Unique Bookings (N)`))
# ### set sharepoint path using csgjcr::csg_sp_path function
# sharepoint_for_policy <- csg_sp_path("JR_NH/Data/for policy team/")
#
# ### export
# write.xlsx(df_nh_other_offense_desc_count_raw,
# file=file.path(sharepoint_for_policy,"nh_raw_offense_descriptions_not_categorized.xlsx"))
### print table via kableextra
kable(df_nh_other_offense_desc_count_top_20,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l")
```
<br><br>
# Analysis
<br>
## Charge Data Tables (most serious charge)
### Table 1. Charge Type by Jail (Non-PC Holds Only)
```{r echo=FALSE,message=FALSE,warning=FALSE}
### unique bookings per charge type by county
df_county_level_charge_type_summary <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
dplyr::group_by(county) %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
ungroup() %>%
distinct() %>%
dplyr::rename(`County` = county)
### overall bookings by charge type for nh
df_county_level_charge_type_summary_statewide <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
mutate(`County` = "Statewide")
### combine tables for kable
table_county_level_charge_type_summary_final <- rbind(df_county_level_charge_type_summary,
df_county_level_charge_type_summary_statewide)
### print table via kableextra
kable(table_county_level_charge_type_summary_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(9, bold = TRUE)
```
<br><br>
### Table 2. Charge Type over Time (Non-PC Holds Only)
Note: These booking frequencies by charge type are grouped by fiscal year of booking
```{r echo=FALSE,message=FALSE,warning=FALSE}
### unique bookings per charge type by fiscal year
df_fy_charge_type_summary <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
dplyr::group_by(fy) %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
ungroup() %>%
distinct() %>%
dplyr::rename(`Fiscal Year` = fy)
### overall bookings by charge type for nh
df_fy_charge_type_summary_statewide <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
mutate(`Fiscal Year` = "Overall")
### combine tables for kable
table_fy_charge_type_summary_final <- rbind(df_fy_charge_type_summary,
df_fy_charge_type_summary_statewide)
### print table via kableextra
kable(table_fy_charge_type_summary_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(4, bold = TRUE)
```
<br><br>
### Table 2.5. Charge Type by Race/Ethnicity (Non-PC Holds Only)
Note: These booking frequencies by charge type are grouped by fiscal year of booking
```{r echo=FALSE,message=FALSE,warning=FALSE}
### unique bookings per charge type by fiscal year
df_race_charge_type_summary <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
filter(!is.na(race)) %>%
dplyr::group_by(race) %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
ungroup() %>%
distinct() %>%
dplyr::rename(`Race/Ethnicity` = race)
### overall bookings by charge type for nh
df_race_charge_type_summary_statewide <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
filter(!is.na(race)) %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
mutate(`Race/Ethnicity` = "Overall")
### combine tables for kable
table_race_charge_type_summary_final <- rbind(df_race_charge_type_summary,
df_race_charge_type_summary_statewide)
### print table via kableextra
kable(table_race_charge_type_summary_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(6, bold = TRUE)
```
<br><br>
### Table 3a. Charge Type for Individuals who are High Utilizers (based on all three years of data)
Note: This output excludes charge type analysis for PC bookings, as no charge information exists, but the high utilizer percentile grouping (developed by Mari) does include PC bookings -- does this make sense?
Below is the preliminary grouping I am using to confirm with the team. With this approach, this is not overlap of groups -- one individual is in one of the four groups (i.e., someone in the top 1% of jail entrances is only included in the 1% grouping, not the 5% and 10% grouping). I'm thinking that this may help us better see any differences between groupings of high utilizers, if they exist. Open to suggestions, though!
* **Top 1%:** individual is in top 1% of jail entrances for all 3 years of sample
* **Top 5%:** individual is in top 5% of jail entrances for all 3 years of sample (really this is 1% to 5%)
* **Top 10%:** individual is in top 10% of jail entrances for all 3 years of sample (really this is 5% to 10%)
* **Non-HU:** individual is not in top 10% of jail entrances for all 3 years of sample
```{r echo=FALSE,message=FALSE,warning=FALSE}
### to recode high utlizer percentile grouping, we don't need to group_by as the percentile grouping is already grouped across individual from Mari's cleaning
nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
### to ensure each individual/booking is in correct grouping, start with Non-HU, then 10% and move down to 1%
mutate(hu_group_exclusive = case_when(
high_utilizer_10_pct=="No" ~ 4,
high_utilizer_10_pct=="Yes" & high_utilizer_5_pct=="No" & high_utilizer_1_pct=="No" ~ 3,
high_utilizer_5_pct=="Yes" & high_utilizer_1_pct=="No" ~ 2,
high_utilizer_1_pct=="Yes" ~ 1,
TRUE ~ as.numeric(NA)),
hu_group_exclusive = factor(hu_group_exclusive,
levels = c(1,2,3,4),
labels = c("Top 1%", "Top 5%", "Top 10%", "Non-HU")))
### unique bookings per charge type by HU grouping
df_hu_charge_type_summary <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode %>%
dplyr::group_by(hu_group_exclusive) %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
ungroup() %>%
distinct() %>%
dplyr::rename(`High Utilizer Percentiles` = hu_group_exclusive)
### overall bookings by charge type for nh
df_hu_charge_type_summary_overall <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
mutate(`High Utilizer Percentiles` = "Overall")
### combine tables for kable
table_hu_charge_type_summary_final <- rbind(df_hu_charge_type_summary,
df_hu_charge_type_summary_overall)
### print table via kableextra
kable(table_hu_charge_type_summary_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(5, bold = TRUE)
```
<br><br>
### Table 3b. Public Order Charge Description for Individuals who are High Utilizers (based on all three years of data)
* **Top 1%:** individual is in top 1% of jail entrances for all 3 years of sample
* **Top 5%:** individual is in top 5% of jail entrances for all 3 years of sample (really this is 1% to 5%)
* **Top 10%:** individual is in top 10% of jail entrances for all 3 years of sample (really this is 5% to 10%)
* **Non-HU:** individual is not in top 10% of jail entrances for all 3 years of sample
```{r echo=FALSE,message=FALSE,warning=FALSE}
### create denominators -- unique bookings for sub-sample
unique_bookings_public_order_denom_top_1 <- n_distinct(nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$unique_booking_id_nh[nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$crime_type_lookup=="Public Order" & nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$hu_group_exclusive=="Top 1%"],
na.rm = TRUE)
unique_bookings_public_order_denom_top_5 <- n_distinct(nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$unique_booking_id_nh[nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$crime_type_lookup=="Public Order" & nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$hu_group_exclusive=="Top 5%"],
na.rm = TRUE)
unique_bookings_public_order_denom_top_10 <- n_distinct(nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$unique_booking_id_nh[nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$crime_type_lookup=="Public Order" & nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$hu_group_exclusive=="Top 10%"],
na.rm = TRUE)
unique_bookings_public_order_denom_non_hu <- n_distinct(nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$unique_booking_id_nh[nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$crime_type_lookup=="Public Order" & nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode$hu_group_exclusive=="Non-HU"],
na.rm = TRUE)
### unique bookings per charge type by HU grouping
df_hu_public_order_charge_type_summary <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode %>%
filter(crime_type_lookup=="Public Order") %>%
dplyr::group_by(statute_title_lookup) %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Top 1% HU (Column %)` = scales::percent(n_distinct(unique_booking_id_nh[hu_group_exclusive=="Top 1%"])/unique_bookings_public_order_denom_top_1,
accuracy = .1),
`Bookings for Top 5% HU (Column %)` = scales::percent(n_distinct(unique_booking_id_nh[hu_group_exclusive=="Top 5%"])/unique_bookings_public_order_denom_top_5,
accuracy = .1),
`Bookings for Top 10% HU (Column %)` = scales::percent(n_distinct(unique_booking_id_nh[hu_group_exclusive=="Top 10%"])/unique_bookings_public_order_denom_top_10,
accuracy = .1),
`Bookings for Top Non-HU (Column %)` = scales::percent(n_distinct(unique_booking_id_nh[hu_group_exclusive=="Non-HU"])/unique_bookings_public_order_denom_non_hu,
accuracy = .1)) %>%
ungroup() %>%
dplyr::rename(`Charge Description` = statute_title_lookup)
### overall bookings by charge type for nh
df_hu_charge_type_summary_overall <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode %>%
filter(crime_type_lookup=="Public Order") %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Top 1% HU (Column %)` = scales::percent(n_distinct(unique_booking_id_nh[hu_group_exclusive=="Top 1%"])/unique_bookings_public_order_denom_top_1,
accuracy = .1),
`Bookings for Top 5% HU (Column %)` = scales::percent(n_distinct(unique_booking_id_nh[hu_group_exclusive=="Top 5%"])/unique_bookings_public_order_denom_top_5,
accuracy = .1),
`Bookings for Top 10% HU (Column %)` = scales::percent(n_distinct(unique_booking_id_nh[hu_group_exclusive=="Top 10%"])/unique_bookings_public_order_denom_top_10,
accuracy = .1),
`Bookings for Top Non-HU (Column %)` = scales::percent(n_distinct(unique_booking_id_nh[hu_group_exclusive=="Non-HU"])/unique_bookings_public_order_denom_non_hu,
accuracy = .1)) %>%
mutate(`Charge Description` = "Overall")
### combine tables for kable
df_hu_public_order_charge_type_summary_final <- rbind(df_hu_public_order_charge_type_summary,
df_hu_charge_type_summary_overall)
### print table via kableextra
kable(df_hu_public_order_charge_type_summary_final,
format.args = list(big.mark = ","),
align=rep('c')) %>%
kable_styling(bootstrap_options = c("striped",
"hover",
"condensed",
"responsive"),
row_label_position = "l") %>%
row_spec(15, bold = TRUE)
```
<br><br>
```{r eval=FALSE,include=FALSE,message=FALSE,warning=FALSE}
### Table 4. Charge Type for Individuals who are High Utilizers (based on single fiscal year calculations)
# Note: This output excludes charge type analysis for PC bookings, as no charge information exists, but the high utilizer percentile grouping (developed by Mari) does include PC bookings -- does this make sense?
#
# Below is the preliminary grouping I am using to confirm with the team. With this approach, this is not overlap of groups -- one individual is in one of the four groups (i.e., someone in the top 1% of jail entrances is only included in the 1% grouping, not the 5% and 10% grouping). I'm thinking that this may help us better see any differences between groupings of high utilizers, if they exist. Open to suggestions, though!
#
# * **Top 1%:** individual is in top 1% of jail entrances for the given fiscal year of booking
#
# * **Top 5%:** individual is in top 5% of jail entrances for the given fiscal year of booking(really this is 1% to 5%)
#
# * **Top 10%:** individual is in top 10% of jail entrances for the given fiscal year of booking (really this is 5% to 10%)
#
# * **Non-HU:** individual is not in top 10% of jail entrances for the given fiscal year of booking
### to recode high utlizer percentile grouping, we don't need to group_by as the percentile grouping is already grouped across individual from Mari's cleaning
nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode_fy <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc %>%
### to ensure each individual/booking is in correct grouping, start with Non-HU, then 10% and move down to 1%
mutate(hu_group_exclusive_fy = case_when(
high_utilizer_10_pct_fy=="No" ~ 4,
high_utilizer_10_pct_fy=="Yes" & high_utilizer_5_pct_fy=="No" & high_utilizer_1_pct_fy=="No" ~ 3,
high_utilizer_5_pct_fy=="Yes" & high_utilizer_1_pct_fy=="No" ~ 2,
high_utilizer_1_pct_fy=="Yes" ~ 1,
TRUE ~ as.numeric(NA)),
hu_group_exclusive_fy = factor(hu_group_exclusive_fy,
levels = c(1,2,3,4),
labels = c("Top 1%", "Top 5%", "Top 10%", "Non-HU")))
### unique bookings per charge type by HU grouping
df_hu_charge_type_summary_fy <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode_fy %>%
dplyr::group_by(hu_group_exclusive_fy) %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for FTA/Bail (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="FTA/Bail"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Temporary Hold (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Temporary Hold"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Other Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Other"])/`Unique Non-PC Bookings (N)`,
accuracy = .1)) %>%
ungroup() %>%
distinct() %>%
dplyr::rename(`High Utilizer Percentiles (FY)` = hu_group_exclusive_fy)
### overall bookings by charge type for nh
df_hu_charge_type_summary_overall_fy <- nh_eight_county_charge_clean_final_crime_type_recode_non_pc_hu_recode_fy %>%
dplyr::summarise(`Unique Non-PC Bookings (N)` = n_distinct(unique_booking_id_nh),
`Bookings for Violent Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Violent"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Property Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Property"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Drug/Alcohol Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Drug/Alcohol"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Public Order Charge (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Public Order"])/`Unique Non-PC Bookings (N)`,
accuracy = .1),
`Bookings for Probation/Parole Violation (%)` = scales::percent(n_distinct(unique_booking_id_nh[crime_type_clean=="Probation/Parole Violation"])/`Unique Non-PC Bookings (N)`,