-
Notifications
You must be signed in to change notification settings - Fork 0
/
asa_2021.Rmd
1502 lines (1235 loc) · 56.8 KB
/
asa_2021.Rmd
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: "ASA Data Challenge Expo"
output:
html_document: default
pdf_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Helping Communities During the COVID-19 Pandemic
### Entry Details
* Event: [2021 ASA Data Challenge Expo][00.00]
* Name: Walter Yu
* Organization: [Code for America][00.13]
* Section: [Sacramento Brigade][00.14]
* Code Repository: [Github][00.15]
[00.00]: https://community.amstat.org/dataexpo/home
[00.13]: https://www.codeforamerica.org/
[00.14]: https://codeforsacramento.org/
[00.15]: https://github.com/walteryu/asa-2021
### Executive Summary
This project aims to help disadvantaged communities during the COVID-19 pandemic by answering the questions listed below through analysis of core and supplemental datasets. The intended audience are state/local governments, non-governmental organizations (NGOs) and volunteers which are able to provide aid and services to these communities.
1. Explore the relationship between socioeconomic features of the U.S. population and disadvantaged communities.
2. Identify disadvantaged communities based on their median household income. These communities are likely be more impacted by the COVID-19 pandemic and in need of public services.
3. Provide recommendations on helping these communities based on data analysis results.
### Scope
This entry focuses on California communities to control its scope since several questions are being considered, and data analysis of all U.S. communities would expand the scope and length of this report. This limited scope provides for more detail and attention to be paid to analysis, documentation and recommendations.
## Part 1: Overview
### Methodology
This project and its analysis are designed to be interpretable, so it organizes data analysis steps into the following modules:
1. Overview: Outline approach, assumptions and data sources
2. Data Processing: Data preparation for analysis
3. Data Analysis: Model fit, coefficient interpretation and diagnostics
4. Recommendations: Document key findings from data analysis
5. Future Improvements: Possible improvements upon completing analysis
### Assumptions
This entry makes the following assumptions:
1. Although the scope is limited to California communities, the methodology may be applied to other states since it is based on data extracted from the U.S. Census for the state/county level and do not contain any characteristics specific to California.
2. State and federal [guidelines][00.11] typically define disadvantaged communities as being low-income, so median household income was used to identify such communities. In addition, state and federal guidelines typically define low income as 20% of median household income.
3. Data analysis was documented to be clear and easily interpretable, so linear regression and the [Law of Parsimony][00.12] were applied whenever possible. The linear models are improved incrementally upon for interpretability.
[00.11]: https://www.hud.gov/topics/rental_assistance/phprog
[00.12]: https://en.wikipedia.org/wiki/Occam%27s_razor
### Data Summary
This entry analyzes core and supplemental datasets from the data challenge [problem statement][00.01] as follows:
* Core Dataset: 2019 American Community Survey (ACS) Single-Year Estimates
* Supplemental Dataset: COVID-19 Data from the National Center for Health Statistics
Data was downloaded from portal websites as follows:
1. U.S. Census Website: Advanced [search feature][00.02] was used to filter data in the following order: Surveys > Years > Geography > Topics.
2. U.S. Census COVID-19 Website: CA state data was downloaded from the [categorical dataset search page][00.03].
3. National Center for Health Statistics (NCHS) Website: Death counts by county and race downloaded from their [data portal][00.04].
[00.01]: https://opportunity.census.gov/assets/files/covid-19-top-asa-problem-statement.pdf
[00.02]: https://data.census.gov/cedsci/advanced
[00.03]: https://covid19.census.gov/
[00.04]: https://www.cdc.gov/nchs/covid19/index.htm
### Core Datasets
Datasets of interest were identified from the U.S. Census data portal and extracted using the advanced search tool. Table ID numbers are listed for reference.
1. 2019 American Community Survey (ACS) Single-Year Estimates - Language Spoken
* Description: PLACE OF BIRTH BY LANGUAGE SPOKEN AT HOME AND ABILITY TO SPEAK ENGLISH IN THE UNITED STATES
* Survey/Program: American Community Survey
* Years: 2019
* Table: [B06007][01.00]
[01.00]: https://data.census.gov/cedsci/table?q=B06007&tid=ACSDT1Y2019.B06007
2. 2019 American Community Survey (ACS) Single-Year Estimates - Household Income
* Description: HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS)
* Survey/Program: American Community Survey
* Years: 2019
* Table: [B19001][01.01]
[01.01]: https://data.census.gov/cedsci/table?text=B19001&tid=ACSDT1Y2019.B19001
3. 2019 American Community Survey (ACS) Single-Year Estimates - Median Household Income
* Description: MEDIAN HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 2019 INFLATION-ADJUSTED DOLLARS)
* Survey/Program: American Community Survey
* Years: 2019
* Table: [B19013][01.02]
[01.02]: https://data.census.gov/cedsci/table?text=B19013&tid=ACSDT1Y2019.B19013
4. 2019 American Community Survey (ACS) Single-Year Estimates - Poverty Status
* Description: POVERTY STATUS IN THE PAST 12 MONTHS BY SEX BY AGE
* Survey/Program: American Community Survey
* Years: 2019
* Table: [B17001][01.03]
[01.03]: https://data.census.gov/cedsci/table?text=B17001&tid=ACSDT1Y2019.B17001
5. 2019 American Community Survey (ACS) Single-Year Estimates - Housing Cost
* Description: MONTHLY HOUSING COSTS
* Survey/Program: American Community Survey
* Years: 2019
* Table: [B25104][01.04]
[01.04]: https://data.census.gov/cedsci/table?text=B25104&tid=ACSDT1Y2019.B25104
6. 2019 American Community Survey (ACS) Single-Year Estimates - Education Attainment
* Description: EDUCATIONAL ATTAINMENT FOR THE POPULATION 25 YEARS AND OVER
* Survey/Program: American Community Survey
* Years: 2019
* Table: [B15003][01.05]
[01.05]: https://data.census.gov/cedsci/table?text=B15003&tid=ACSDT1Y2019.B15003
7. 2019 American Community Survey (ACS) Single-Year Estimates - Commute Mode
* Description: MEANS OF TRANSPORTATION TO WORK BY AGE
* Survey/Program: American Community Survey
* Years: 2019
* Table: [B08101][01.06]
[01.06]: https://data.census.gov/cedsci/table?text=B08101&tid=ACSDT1Y2019.B08101
8. 2019 American Community Survey (ACS) Single-Year Estimates - Race
* Description: RACE
* Survey/Program: American Community Survey
* Years: 2019
* Table: [B02001][01.07]
[01.07]: https://data.census.gov/cedsci/table?text=B02001&tid=ACSDT1Y2019.B02001
### Supplemental Datasets (U.S. Census)
Datasets of interest were identified from the U.S. Census COVID-19 data portal under the categorical dataset section.
1. U.S. Census - COVID-19 Demographic and Economic Resources
* Dataset: [California Counties DP02 Social][02.00]
[02.00]: https://covid19.census.gov/datasets/california-counties-dp02-social
2. U.S. Census - COVID-19 Demographic and Economic Resources
* Dataset: [California Counties DP03 Economic][02.01]
[02.01]: https://covid19.census.gov/datasets/california-counties-dp03-economic
3. U.S. Census - COVID-19 Demographic and Economic Resources
* Dataset: [California Counties DP04 Housing][02.02]
[02.02]: https://covid19.census.gov/datasets/california-counties-dp04-housing
4. U.S. Census - COVID-19 Demographic and Economic Resources
* Dataset: [California Counties DP05 Demographic][02.03]
[02.03]: https://covid19.census.gov/datasets/california-counties-dp05-demographic
5. U.S. Census - COVID-19 Demographic and Economic Resources
* Dataset: [Household Pulse Survey Public Use File][02.04]
[02.04]: https://www.census.gov/programs-surveys/household-pulse-survey/datasets.html
6. U.S. Census - COVID-19 Demographic and Economic Resources
* Dataset: [COVID-19 Case Surveillance Public Use Data][02.05]
[02.05]: https://data.cdc.gov/Case-Surveillance/COVID-19-Case-Surveillance-Public-Use-Data/vbim-akqf
### Supplemental Datasets (NCHS)
Datasets of interest were identified from the National Center for Health Statistics (NCHS) data portal for COVID-related mortality count by California county to evaluate impacts by the pandemic.
1. NCHS - COVID-19 Data from the National Center for Health Statistics
* Dataset: [Provisional COVID-19 Death Counts by County and Race][02.06]
[02.06]: https://data.cdc.gov/NCHS/Provisional-COVID-19-Death-Counts-by-County-and-Ra/k8wy-p9cg
2. NCHS - COVID-19 Data from the National Center for Health Statistics
* Dataset: [Provisional COVID-19 Death Counts in the United States by County][02.07]
[02.07]: https://data.cdc.gov/NCHS/Provisional-COVID-19-Death-Counts-in-the-United-St/kn79-hsxy
### Geospatial Datasets
Datasets of interest were identified from the U.S. Census COVID-19 data portal under the categorical dataset section. They were not used during the analysis due to time and scope constraints so are documented for future use.
1. U.S. Census - COVID-19 Demographic and Economic Resources
* Description: American Community Survey (ACS) about household income ranges and cutoffs and Poverty Status.
* These are 5-year estimates shown by state and county boundaries.
* Link: [Dataset][03.00]
[03.00]: https://uscensus.maps.arcgis.com/home/item.html?id=b2ba19b4cce04a9796d9cdeecaba2f18
2. U.S. Census - COVID-19 Demographic and Economic Resources
* Description: American Community Survey (ACS) about household income ranges and cutoffs.
* These are 5-year estimates shown by county, and state boundaries.
* Link: [Dataset][03.01]
[03.01]: https://uscensus.maps.arcgis.com/home/item.html?id=0fbb1571e5b6458f941580d1d64a6693
3. U.S. Census - COVID-19 Demographic and Economic Resources
* Description: American Community Survey (ACS) about total population count by sex and age group.
* These are 5-year estimates shown by state and county boundaries.
* Link: [Dataset][03.02]
[03.02]: https://uscensus.maps.arcgis.com/home/item.html?id=eab0f44ba5184c609175caa7ae317f0c
## Part 2: Data Processing
### Methodology
> Core and supplemental datasets of interested were processed and joined as listed below prior to model fit and data visualization.
This module completes the tasks listed below; however, all text output, warnings and messages are silenced to minimize report length so please check the code repository for details about implementation.
1. Import csv files as dataframes
2. Remove first record from each dataframe (header data)
3. Import selected columns from full dataset
4. Relabel selected columns from full dataset
5. Total population below 20% of median household income
6. Join tables together into single dataframe
```{r echo=FALSE, message=FALSE, warning=FALSE}
# data processing package
library(dplyr)
# data source: U.S. Census Data Portal
acs19_language <- read.csv(
# "https://data.census.gov/cedsci/table?q=B06007&tid=ACSDT1Y2019.B06007.csv"
"data/ACSDT1Y2019.B06007_data_with_overlays_2020-11-18T232550.csv"
)
# data source: U.S. Census Data Portal
acs19_hh_income <- read.csv(
# "https://data.census.gov/cedsci/table?text=B19001&tid=ACSDT1Y2019.B19001.csv"
"data/ACSDT1Y2019.B19001_data_with_overlays_2020-11-22T010349.csv"
)
# data source: U.S. Census Data Portal
acs19_hh_income_median <- read.csv(
# "https://data.census.gov/cedsci/table?text=B19013&tid=ACSDT1Y2019.B19013.csv"
"data/ACSDT1Y2019.B19013_data_with_overlays_2020-11-22T035924.csv"
)
# data source: U.S. Census Data Portal
acs19_poverty <- read.csv(
# "https://data.census.gov/cedsci/table?text=B17001&tid=ACSDT1Y2019.B17001.csv"
"data/ACSDT1Y2019.B17001_data_with_overlays_2020-11-22T010613.csv"
)
# data source: U.S. Census Data Portal
acs19_housing <- read.csv(
# "https://data.census.gov/cedsci/table?text=B25104&tid=ACSDT1Y2019.B25104.csv"
"data/ACSDT1Y2019.B25104_data_with_overlays_2020-11-22T003237.csv"
)
# data source: U.S. Census Data Portal
acs19_education <- read.csv(
# "https://data.census.gov/cedsci/table?text=B15003&tid=ACSDT1Y2019.B15003.csv"
"data/ACSDT1Y2019.B15003_data_with_overlays_2020-11-22T004032.csv"
)
# data source: U.S. Census Data Portal
acs19_commute <- read.csv(
# "https://data.census.gov/cedsci/table?text=B08101&tid=ACSDT1Y2019.B08101.csv"
"data/ACSDT1Y2019.B08101_data_with_overlays_2020-11-22T004429.csv"
)
# data source: U.S. Census Data Portal
acs19_race <- read.csv(
# "https://data.census.gov/cedsci/table?text=B02001&tid=ACSDT1Y2019.B02001.csv"
"data/ACSDT1Y2019.B02001_data_with_overlays_2020-11-22T010027.csv"
)
# show table dim
# print("Show table dimensions below:")
# dim(acs19_language)
# dim(acs19_hh_income)
# dim(acs19_hh_income_median)
# dim(acs19_poverty)
# dim(acs19_housing)
# dim(acs19_education)
# dim(acs19_commute)
# dim(acs19_race)
# remove first row
acs19_language = acs19_language[-1, ]
acs19_hh_income = acs19_hh_income[-1, ]
acs19_hh_income_median = acs19_hh_income_median[-1, ]
acs19_poverty = acs19_poverty[-1, ]
acs19_housing = acs19_housing[-1, ]
acs19_education = acs19_education[-1, ]
acs19_commute = acs19_commute[-1, ]
acs19_race = acs19_race[-1, ]
# preview table rows
# print("Preview table rows below:")
# head(acs19_language)
# head(acs19_hh_income)
# head(acs19_hh_income_median)
# head(acs19_poverty)
# head(acs19_housing)
# head(acs19_education)
# head(acs19_commute)
# head(acs19_race)
# subset each table before join
# 1. 2019 American Community Survey (ACS) Single-Year Estimates - Language Spoken
# * Table: [B06007]
# * Columns:
# B06007_002E: Speak only English
# B06007_004E: Speak Spanish:!!Speak English "very well"
# B06007_005E: Speak other languages:!!Speak English "very well"
# subset by columns
# https://www.statmethods.net/management/subset.html
var_lang = c(
"GEO_ID",
"B06007_002E",
"B06007_004E",
"B06007_005E"
)
xwalk_acs19_lang = acs19_language[var_lang]
# rename columns
# https://www.datanovia.com/en/lessons/rename-data-frame-columns-in-r/
xwalk_acs19_lang = xwalk_acs19_lang %>%
rename(
lang_english = B06007_002E,
lang_spanish = B06007_004E,
lang_other = B06007_005E
)
# show table dim
# print("Show table dimensions below:")
# head(xwalk_acs19_lang)
# dim(xwalk_acs19_lang)
# 2. 2019 American Community Survey (ACS) Single-Year Estimates - Household Income
# * Table: [B19001]
# * Columns:
# B19001_002E: Estimate!!Total:!!Less than $10,000
# B19001_003E: Estimate!!Total:!!$10,000 to $14,999
# B19001_004E: Estimate!!Total:!!$15,000 to $19,999
# B19001_005E: Estimate!!Total:!!$20,000 to $24,999
# B19001_006E: Estimate!!Total:!!$25,000 to $29,999
# B19001_007E: Estimate!!Total:!!$30,000 to $34,999
# B19001_008E: Estimate!!Total:!!$35,000 to $39,999
# B19001_009E: Estimate!!Total:!!$40,000 to $44,999
# B19001_010E: Estimate!!Total:!!$45,000 to $49,999
# B19001_011E: Estimate!!Total:!!$50,000 to $59,999
# B19001_012E: Estimate!!Total:!!$60,000 to $74,999
# B19001_013E: Estimate!!Total:!!$75,000 to $99,999
# B19001_014E: Estimate!!Total:!!$100,000 to $124,999
# B19001_015E: Estimate!!Total:!!$125,000 to $149,999
# B19001_016E: Estimate!!Total:!!$150,000 to $199,999
# B19001_017E: Estimate!!Total:!!$200,000 or more
# subset by columns
# https://www.statmethods.net/management/subset.html
var_hh = c(
"GEO_ID",
"B19001_002E",
"B19001_003E",
"B19001_004E",
"B19001_005E",
"B19001_006E",
"B19001_007E",
"B19001_008E",
"B19001_009E",
"B19001_010E",
"B19001_011E",
"B19001_012E",
"B19001_013E",
"B19001_014E",
"B19001_015E",
"B19001_016E",
"B19001_017E"
)
xwalk_acs19_hh = acs19_hh_income[var_hh]
# rename columns
# https://www.datanovia.com/en/lessons/rename-data-frame-columns-in-r/
xwalk_acs19_hh = xwalk_acs19_hh %>%
rename(
hh_less_10k = B19001_002E,
hh_10k = B19001_003E,
hh_15k = B19001_004E,
hh_20k = B19001_005E,
hh_25k = B19001_006E,
hh_30k = B19001_007E,
hh_35k = B19001_008E,
hh_40k = B19001_009E,
hh_45k = B19001_010E,
hh_50k = B19001_011E,
hh_60k = B19001_012E,
hh_75k = B19001_013E,
hh_100k = B19001_014E,
hh_125k = B19001_015E,
hh_150k = B19001_016E,
hh_200k = B19001_017E
)
# show table dim
# print("Show table dimensions below:")
# head(xwalk_acs19_hh)
# dim(xwalk_acs19_hh)
# 3. 2019 American Community Survey (ACS) Single-Year Estimates - Median Household Income
# * Table: [B19013]
# * Columns:
# B19013_001E: Estimate!!Median household income in the past 12 months
# subset by columns
# https://www.statmethods.net/management/subset.html
var_hh_median = c(
"GEO_ID",
"B19013_001E"
)
xwalk_acs19_hh_median = acs19_hh_income_median[var_hh_median]
# rename columns
# https://www.datanovia.com/en/lessons/rename-data-frame-columns-in-r/
xwalk_acs19_hh_median = xwalk_acs19_hh_median %>%
rename(
hh_median = B19013_001E
)
# total population count below 20% of median household income ($56k/year)
# https://stackoverflow.com/questions/26046776/sum-two-columns-in-r
xwalk_acs19_hh$hh_less_10k = as.numeric(as.character(xwalk_acs19_hh$hh_less_10k))
xwalk_acs19_hh$hh_10k = as.numeric(as.character(xwalk_acs19_hh$hh_10k))
xwalk_acs19_hh$hh_15k = as.numeric(as.character(xwalk_acs19_hh$hh_15k))
xwalk_acs19_hh$hh_20k = as.numeric(as.character(xwalk_acs19_hh$hh_20k))
xwalk_acs19_hh$hh_25k = as.numeric(as.character(xwalk_acs19_hh$hh_25k))
xwalk_acs19_hh$hh_30k = as.numeric(as.character(xwalk_acs19_hh$hh_30k))
xwalk_acs19_hh$hh_35k = as.numeric(as.character(xwalk_acs19_hh$hh_35k))
xwalk_acs19_hh$hh_40k = as.numeric(as.character(xwalk_acs19_hh$hh_40k))
xwalk_acs19_hh$hh_45k = as.numeric(as.character(xwalk_acs19_hh$hh_45k))
xwalk_acs19_hh$hh_50k = as.numeric(as.character(xwalk_acs19_hh$hh_50k))
# total population count below 20% of median household income ($56k/year)
# https://stackoverflow.com/questions/26046776/sum-two-columns-in-r
xwalk_acs19_hh_median$hh_median = xwalk_acs19_hh$hh_less_10k +
xwalk_acs19_hh$hh_10k +
xwalk_acs19_hh$hh_15k +
xwalk_acs19_hh$hh_20k +
xwalk_acs19_hh$hh_25k +
xwalk_acs19_hh$hh_30k +
xwalk_acs19_hh$hh_35k +
xwalk_acs19_hh$hh_40k +
xwalk_acs19_hh$hh_45k +
xwalk_acs19_hh$hh_50k
# xwalk_acs19_hh_median$hh_median
# show table dim
# print("Show table dimensions below:")
# head(xwalk_acs19_hh_median)
# dim(xwalk_acs19_hh_median)
# 4. 2019 American Community Survey (ACS) Single-Year Estimates - Poverty Status
# * Table: [B17001]
# * Columns:
# B17001_002E: Estimate!!Total:!!Income in the past 12 months below poverty level:
# B17001_031E: Estimate!!Total:!!Income in the past 12 months at or above poverty level:
# subset by columns
# https://www.statmethods.net/management/subset.html
var_poverty = c(
"GEO_ID",
"B17001_002E",
"B17001_031E"
)
xwalk_acs19_poverty = acs19_poverty[var_poverty]
# rename columns
# https://www.datanovia.com/en/lessons/rename-data-frame-columns-in-r/
xwalk_acs19_poverty = xwalk_acs19_poverty %>%
rename(
poverty_below = B17001_002E,
poverty_above = B17001_031E,
)
# show table dim
# print("Show table dimensions below:")
# head(xwalk_acs19_poverty)
# dim(xwalk_acs19_poverty)
# 5. 2019 American Community Survey (ACS) Single-Year Estimates - Housing Cost
# * Table: [B25104]
# * Columns:
# B25104_002E: Estimate!!Total:!!Less than $100
# B25104_003E: Estimate!!Total:!!$100 to $199
# B25104_004E: Estimate!!Total:!!$200 to $299
# B25104_005E: Estimate!!Total:!!$300 to $399
# B25104_006E: Estimate!!Total:!!$400 to $499
# B25104_007E: Estimate!!Total:!!$500 to $599
# B25104_008E: Estimate!!Total:!!$600 to $699
# B25104_009E: Estimate!!Total:!!$700 to $799
# B25104_010E: Estimate!!Total:!!$800 to $899
# B25104_011E: Estimate!!Total:!!$900 to $999
# B25104_012E: Estimate!!Total:!!$1,000 to $1,499
# B25104_013E: Estimate!!Total:!!$1,500 to $1,999
# B25104_014E: Estimate!!Total:!!$2,000 to $2,499
# B25104_015E: Estimate!!Total:!!$2,500 to $2,999
# B25104_016E: Estimate!!Total:!!$3,000 or more
# B25104_017E: Estimate!!Total:!!No cash rent
# subset by columns
# https://www.statmethods.net/management/subset.html
var_housing = c(
"GEO_ID",
"B25104_002E",
"B25104_003E",
"B25104_004E",
"B25104_005E",
"B25104_006E",
"B25104_007E",
"B25104_008E",
"B25104_009E",
"B25104_010E",
"B25104_011E",
"B25104_012E",
"B25104_013E",
"B25104_014E",
"B25104_015E",
"B25104_016E",
"B25104_017E"
)
xwalk_acs19_housing = acs19_housing[var_housing]
# rename columns
# https://www.datanovia.com/en/lessons/rename-data-frame-columns-in-r/
xwalk_acs19_housing = xwalk_acs19_housing %>%
rename(
housing_less_100 = B25104_002E,
housing_100 = B25104_003E,
housing_200 = B25104_004E,
housing_300 = B25104_005E,
housing_400 = B25104_006E,
housing_500 = B25104_007E,
housing_600 = B25104_008E,
housing_700 = B25104_009E,
housing_800 = B25104_010E,
housing_900 = B25104_011E,
housing_1000 = B25104_012E,
housing_1500 = B25104_013E,
housing_2000 = B25104_014E,
housing_2500 = B25104_015E,
housing_more_3000 = B25104_016E,
housing_rent_free = B25104_017E
)
# show table dim
# print("Show table dimensions below:")
# head(xwalk_acs19_housing)
# dim(xwalk_acs19_housing)
# 6. 2019 American Community Survey (ACS) Single-Year Estimates - Education Attainment
# * Table: [B15003]
# * Columns:
# B15003_002E: Estimate!!Total:!!No schooling completed
# B15003_003E: Estimate!!Total:!!Nursery school
# B15003_004E: Estimate!!Total:!!Kindergarten
# B15003_005E: Estimate!!Total:!!1st grade
# B15003_006E: Estimate!!Total:!!2nd grade
# B15003_007E: Estimate!!Total:!!3rd grade
# B15003_008E: Estimate!!Total:!!4th grade
# B15003_009E: Estimate!!Total:!!5th grade
# B15003_010E: Estimate!!Total:!!6th grade
# B15003_011E: Estimate!!Total:!!7th grade
# B15003_012E: Estimate!!Total:!!8th grade
# B15003_013E: Estimate!!Total:!!9th grade
# B15003_014E: Estimate!!Total:!!10th grade
# B15003_015E: Estimate!!Total:!!11th grade
# B15003_016E: Estimate!!Total:!!12th grade, no diploma
# B15003_017E: Estimate!!Total:!!Regular high school diploma
# B15003_018E: Estimate!!Total:!!GED or alternative credential
# B15003_019E: Estimate!!Total:!!Some college, less than 1 year
# B15003_020E: Estimate!!Total:!!Some college, 1 or more years, no degree
# B15003_021E: Estimate!!Total:!!Associate's degree
# B15003_022E: Estimate!!Total:!!Bachelor's degree
# B15003_023E: Estimate!!Total:!!Master's degree
# B15003_024E: Estimate!!Total:!!Professional school degree
# B15003_025E: Estimate!!Total:!!Doctorate degree
# subset by columns
# https://www.statmethods.net/management/subset.html
var_edu = c(
"GEO_ID",
"B15003_002E",
"B15003_003E",
"B15003_004E",
"B15003_005E",
"B15003_006E",
"B15003_007E",
"B15003_008E",
"B15003_009E",
"B15003_010E",
"B15003_011E",
"B15003_012E",
"B15003_013E",
"B15003_014E",
"B15003_015E",
"B15003_016E",
"B15003_017E",
"B15003_018E",
"B15003_019E",
"B15003_020E",
"B15003_021E",
"B15003_022E",
"B15003_023E",
"B15003_024E",
"B15003_025E"
)
xwalk_acs19_edu = acs19_education[var_edu]
# rename columns
# https://www.datanovia.com/en/lessons/rename-data-frame-columns-in-r/
xwalk_acs19_edu = xwalk_acs19_edu %>%
rename(
edu_none = B15003_002E,
edu_nursery = B15003_003E,
edu_kinder = B15003_004E,
edu_grade1 = B15003_005E,
edu_grade2 = B15003_006E,
edu_grade3 = B15003_007E,
edu_grade4 = B15003_008E,
edu_grade5 = B15003_009E,
edu_grade6 = B15003_010E,
edu_grade7 = B15003_011E,
edu_grade8 = B15003_012E,
edu_grade9 = B15003_013E,
edu_grade10 = B15003_014E,
edu_grade11 = B15003_015E,
edu_grade12 = B15003_016E,
edu_hs_only = B15003_017E,
edu_ged_only = B15003_018E,
edu_univ_less1yr = B15003_019E,
edu_univ_more1yr = B15003_020E,
edu_associate = B15003_021E,
edu_bachelor = B15003_022E,
edu_master = B15003_023E,
edu_professional = B15003_024E,
edu_doctorate = B15003_025E
)
# show table dim
# print("Show table dimensions below:")
# head(xwalk_acs19_edu)
# dim(xwalk_acs19_edu)
# 7. 2019 American Community Survey (ACS) Single-Year Estimates - Commute Mode
# * Table: [B08101]
# * Columns:
# B08101_009E: Estimate!!Total:!!Car, truck, or van - drove alone:
# B08101_017E: Estimate!!Total:!!Car, truck, or van - carpooled:
# B08101_025E: Estimate!!Total:!!Public transportation (excluding taxicab):
# B08101_033E: Estimate!!Total:!!Walked:
# B08101_041E: Estimate!!Total:!!Taxicab, motorcycle, bicycle, or other means:
# B08101_049E: Estimate!!Total:!!Worked from home
# subset by columns
# https://www.statmethods.net/management/subset.html
var_commute = c(
"GEO_ID",
"B08101_009E",
"B08101_017E",
"B08101_025E",
"B08101_033E",
"B08101_041E",
"B08101_049E"
)
xwalk_acs19_commute = acs19_commute[var_commute]
# rename columns
# https://www.datanovia.com/en/lessons/rename-data-frame-columns-in-r/
xwalk_acs19_commute = xwalk_acs19_commute %>%
rename(
commute_car = B08101_009E,
commute_carpool = B08101_017E,
commute_transit = B08101_025E,
commute_walk = B08101_033E,
commute_other = B08101_041E,
commute_remote = B08101_049E
)
# show table dim
# print("Show table dimensions below:")
# head(xwalk_acs19_commute)
# dim(xwalk_acs19_commute)
# 8. 2019 American Community Survey (ACS) Single-Year Estimates - Race
# * Table: [B02001]
# * Columns:
# B02001_002E: Estimate!!Total:!!White alone
# B02001_003E: Estimate!!Total:!!Black or African American alone
# B02001_004E: Estimate!!Total:!!American Indian and Alaska Native alone
# B02001_005E: Estimate!!Total:!!Asian alone
# B02001_006E: Estimate!!Total:!!Native Hawaiian and Other Pacific Islander alone
# B02001_007E: Estimate!!Total:!!Some other race alone
# B02001_008E: Estimate!!Total:!!Two or more races:
# subset by columns
# https://www.statmethods.net/management/subset.html
var_race = c(
"GEO_ID",
"B02001_002E",
"B02001_003E",
"B02001_004E",
"B02001_005E",
"B02001_006E",
"B02001_007E",
"B02001_008E"
)
xwalk_acs19_race = acs19_race[var_race]
# show table dim
# print("Show table dimensions below:")
# head(xwalk_acs19_race)
# dim(xwalk_acs19_race)
# inner table joins based on geo_id, then merge into single table
# note: all tables are the same dim except language (1 county short)
# https://mikoontz.github.io/data-carpentry-week/lesson_joins.html
join_acs19_hhm_hh = inner_join(
xwalk_acs19_hh_median,
xwalk_acs19_hh,
by="GEO_ID"
)
join_acs19_pov_hou = inner_join(
xwalk_acs19_poverty,
xwalk_acs19_housing,
by="GEO_ID"
)
join_acs19_edu_com = inner_join(
xwalk_acs19_edu,
xwalk_acs19_commute,
by="GEO_ID"
)
# left join for language since it is short by 1 county
# https://mikoontz.github.io/data-carpentry-week/lesson_joins.html
join_acs19_race_language = left_join(
xwalk_acs19_race,
xwalk_acs19_lang,
by="GEO_ID"
)
# verify that tables joined correctly
# print("Show table dimensions below:")
# dim(join_acs19_hhm_hh)
# dim(join_acs19_pov_hou)
# dim(join_acs19_edu_com)
# dim(join_acs19_race_language)
# inner table joins based on geo_id, then merge into single table
join_acs19_hhm_hou = inner_join(
join_acs19_hhm_hh,
join_acs19_pov_hou,
by="GEO_ID"
)
join_acs19_edu_race = inner_join(
join_acs19_edu_com,
join_acs19_race_language,
by="GEO_ID"
)
# verify that tables joined correctly
# print("Show table dimensions below:")
# dim(join_acs19_hhm_hou)
# dim(join_acs19_edu_race)
# inner table joins based on geo_id, then merge into single table
acs19 = inner_join(
join_acs19_hhm_hou,
join_acs19_edu_race,
by="GEO_ID"
)
# verify that tables joined correctly
# print("Show table dimensions below:")
# dim(acs19)
# str(acs19)
# remove geo_id for regression model fit
# https://stackoverflow.com/questions/5234117/how-to-drop-columns-by-name-in-a-data-frame
acs19_noid = subset(acs19, select=-c(GEO_ID))
# write/read dataframe to remove factor levels
write.csv(acs19_noid, "data/acs19_noid.csv")
acs19_nofactor = read.csv("data/acs19_noid.csv")
# verify that tables joined correctly
# print("Show table dimensions below:")
# dim(acs19_nofactor)
# str(acs19_nofactor)
# evaluate median household income
# hh_median_sw = median(acs19_nofactor$hh_median)
# hh_median_sw
# subset for 0.20 quantile per CA HUD guidelines
# https://www.hcd.ca.gov/grants-funding/income-limits/state-and-federal-income-limits/docs/income-limits-2020.pdf
# hh_median_qt20 = quantile(
# as.numeric(as.character(acs19_nofactor$hh_median)), 0.2
# )
# print("Population Count Below 20% of Median Household Income (2019 ACS):")
# hh_median_qt20
# subset for 0.80 quantile per CA HUD guidelines
# https://www.hcd.ca.gov/grants-funding/income-limits/state-and-federal-income-limits/docs/income-limits-2020.pdf
# hh_median_qt80 = quantile(
# as.numeric(as.character(acs19_nofactor$hh_median)), 0.8
# )
# print("Population Count Above 80% of Median Household Income (2019 ACS):")
# hh_median_qt80
# subset for 0.20 quantile per CA HUD guidelines
# https://www.hcd.ca.gov/grants-funding/income-limits/state-and-federal-income-limits/docs/income-limits-2020.pdf
print("80% of Non-Metropolitan County Median Income (2020 CA HUD Guidelines):")
70700*0.8
```
## Part 3: Data Analysis
### Methodology
> Processed data was fit a linear regression model to identify key attributes associated with disadvantaged communities and those communities most impacted by the pandemic.
Data analysis was conducted as follows:
1. Fit 2019 ACS data tables into separate linear regression models to identify which had the best fit and association with population count below 80% median household income. Model summary was evaluated to identify model fit, p-values and r-squared values.
2. Interpret model fit, coefficient interpretation and model diagnostics to refine model by selecting the best data features and combining into its own linear regression model. Diagnostic plots were reviewed for possible outlier points with high leverage.
3. Identify counties with most residents below 80% median household income and highest COVID-19 death counts by analyzing the 2019 ACS and NCHS COVID-19 mortality count data. Counties with highest count of residents in both datasets were identified and compared.
### 2019 ACS - Commute Mode
> Commute mode has a positive relationship with median household income as verified with the model fit and low p-value. Features were split into two groups for analysis: car-based modes and transit-based modes.
Features within each group were fit individually into their own model. The car-only mode had the best fit in the car-based modes. Walking had the best good fit with transit-based modes. This finding implies that certain commute modes (i.e. car-only and walking) have a better relationship to income than other ones (i.e. carpool and remote work).
The plot shows count of residents below 80% of median income and residents who walks to work. The regression line indicates a negative relationship, so counties with higher low income population had higher population count which walks to work.
The pandemic may impact transit and resulted in additional remote work for the work force. One possible area for analysis would be to determine the level of reliance of residents in disadvantage communities on these modes to evaluate their true impacts.
```{r echo=TRUE, message=FALSE, warning=FALSE}
# features:
# B08101_009E: Car, truck, or van - drove alone
# B08101_017E: Car, truck, or van - carpooled
# B08101_025E: Public transportation (excluding taxicab)
# B08101_033E: Walked
# B08101_041E: Taxicab, motorcycle, bicycle, or other means
# B08101_049E: Worked from home
# model fit for transit-based commute modes
# linear regression - transit
# note: fit to log scale
# source: https://stats.stackexchange.com/questions/176595/simple-log-regression-model-in-r
fit_acs19_commute_walk <- lm(
log(hh_median) ~ log(as.numeric(commute_walk)),
data=acs19_nofactor
)
round(summary(fit_acs19_commute_walk)$coeff, 6)
# linear regression - transit + walk
fit_acs19_commute_transit_walk <- lm(
log(hh_median) ~ log(as.numeric(commute_transit)) +
log(as.numeric(commute_walk)),
data=acs19_nofactor
)
round(summary(fit_acs19_commute_transit_walk)$coeff, 6)
# linear regression - transit + walk + remote
fit_acs19_commute_transit_remote <- lm(
log(hh_median) ~ log(as.numeric(commute_transit)) +
log(as.numeric(commute_walk)) +
log(as.numeric(commute_remote)),
data=acs19_nofactor
)
round(summary(fit_acs19_commute_transit_remote)$coeff, 6)
# variance analysis
anova(
fit_acs19_commute_walk,
fit_acs19_commute_transit_walk,
fit_acs19_commute_transit_remote
)
# model fit for car-based commute modes
# linear regression - car
fit_acs19_commute_car <- lm(
log(hh_median) ~ log(as.numeric(commute_car)),
data=acs19_nofactor
)
round(summary(fit_acs19_commute_car)$coeff, 6)
# linear regression - car + carpool
fit_acs19_commute_car_carpool <- lm(
log(hh_median) ~ log(as.numeric(commute_car)) +
log(as.numeric(commute_carpool)),
data=acs19_nofactor
)
round(summary(fit_acs19_commute_car_carpool)$coeff, 6)
# linear regression - car + carpool + other
fit_acs19_commute_car_other <- lm(
log(hh_median) ~ log(as.numeric(commute_car)) +
log(as.numeric(commute_carpool)) +
log(as.numeric(commute_other)),
data=acs19_nofactor
)
round(summary(fit_acs19_commute_car_other)$coeff, 6)
# variance analysis
anova(
fit_acs19_commute_car,
fit_acs19_commute_car_carpool,
fit_acs19_commute_car_other
)
# visualize income and transit variables
# https://www.theanalysisfactor.com/linear-models-r-plotting-regression-lines/
plot(log(hh_median) ~ log(as.numeric(commute_walk)),
main="Low Income Population and Commute by Walking (Log Scale Plot)",
xlab="Commute by Walking (Count)",
ylab="Below 80% Median Income (Count)",
pch=16,
col="blue",
data=acs19_nofactor
)
# trend line plot
abline(
fit_acs19_commute_walk,
col="red"
)
# linear regression - all
fit_acs19_commute_all <- lm(
log(hh_median) ~ log(as.numeric(commute_transit)) +
log(as.numeric(commute_walk)) +
log(as.numeric(commute_remote)) +
log(as.numeric(commute_car)) +
log(as.numeric(commute_carpool)) +
log(as.numeric(commute_other)),
data=acs19_nofactor
)
summary(fit_acs19_commute_all)
# diagnostic plot
par(mfrow=c(2,2))
plot(fit_acs19_commute_all)
```
### 2019 ACS - Monthly Housing Cost
> Monthly housing cost has a positive relationship with median household income as verified with the model fit and low p-value. The model fit revealed an unexpected result that counties with larger low income populations also had larger populations with high housing cost (above $3k/month). However, this finding may be accounted by counties which are large metro areas tend to have large populations with both categories.
The model fit demonstrated that monthly housing cost is associated with median household income. The model did not include lower housing cost features due to their large number, values with little or not rent and not being adjusted for cost of living (i.e. some counties may have significantly lower rents). As a result, only higher housing cost features were included in the model.
The plot shows count of residents below 80% of median income and residents whose monthly housing income is above $3k per month. The regression line indicates a positive relationship, so counties with higher low income population also had higher population count with high monthly housing cost. This finding is an unexpected but may be accounted by counties which are large metro areas tend to have large populations with both categories.
The pandemic may impact the ability of residents within disadvantaged communities to cover their monthly housing costs. One possible area for analysis would be to determine the ability of residents in disadvantage communities to cover these costs to evaluate their true impacts.
```{r echo=TRUE, message=FALSE, warning=FALSE}
# features:
# B25104_002E: Less than $100
# B25104_003E: 100 to $199
# B25104_004E: 200 to $299
# B25104_005E: 300 to $399
# B25104_006E: 400 to $499
# B25104_007E: 500 to $599
# B25104_008E: 600 to $699
# B25104_009E: 700 to $799
# B25104_010E: 800 to $899
# B25104_011E: 900 to $999
# B25104_012E: 1,000 to $1,499
# B25104_013E: 1,500 to $1,999
# B25104_014E: 2,000 to $2,499
# B25104_015E: 2,500 to $2,999
# B25104_016E: 3,000 or more