Skip to content

Commit d9be7c8

Browse files
authored
Merge pull request #1397 from cmu-delphi/prepare-contingency-historical-backfill
Add older indicators so contingency matches survey API pipeline
2 parents 8b5982f + 5f4ce23 commit d9be7c8

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

facebook/delphiFacebook/R/contingency_indicators.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@ get_aggs <- function() {
7373
## Mask wearing and distancing
7474
"pct_wearing_mask_5d", "c_mask_often", compute_binary, jeffreys_binary,
7575
"pct_wearing_mask_7d", "c_mask_often_7d", compute_binary, jeffreys_binary,
76+
"pct_others_masked", "c_others_masked", compute_binary, jeffreys_binary,
7677
"pct_others_masked_public", "c_others_masked_public", compute_binary, jeffreys_binary,
7778
"pct_others_distanced_public", "c_others_distanced_public", compute_binary, jeffreys_binary,
7879

7980
"pct_cli", "hh_p_cli", compute_household_binary, jeffreys_count,
8081
"pct_ili", "hh_p_ili", compute_household_binary, jeffreys_count,
8182
"pct_hh_cmnty_cli", "hh_community_yes", compute_binary, jeffreys_binary,
83+
"pct_nohh_cmnty_cli", "community_yes", compute_binary, jeffreys_binary,
8284
"pct_direct_contact", "c_direct_contact", compute_binary, jeffreys_binary,
85+
"pct_avoid_contact", "c_avoid_contact", compute_binary, jeffreys_binary,
86+
"pct_avoid_contact_7d", "c_avoid_contact_7d", compute_binary, jeffreys_binary,
8387

8488
# symptoms
8589
"pct_symp_fever", "symp_fever", compute_binary, jeffreys_binary,
@@ -303,8 +307,6 @@ get_aggs <- function() {
303307
"pct_race_treated_fairly_healthcare", "b_race_treated_fairly_healthcare", compute_binary, jeffreys_binary,
304308
"pct_delayed_care_cost", "b_delayed_care_cost", compute_binary, jeffreys_binary,
305309

306-
"pct_worried_catch_covid", "mh_worried_catch_covid", compute_binary, jeffreys_binary,
307-
308310
# topics want to learn about
309311
"pct_want_info_covid_treatment", "i_want_info_covid_treatment", compute_binary, jeffreys_binary,
310312
"pct_want_info_vaccine_access", "i_want_info_vaccine_access", compute_binary, jeffreys_binary,
@@ -355,6 +357,8 @@ get_aggs <- function() {
355357
"pct_anxious_7d", "mh_anxious_7d", compute_binary, jeffreys_binary,
356358
"pct_depressed_7d", "mh_depressed_7d", compute_binary, jeffreys_binary,
357359
"pct_felt_isolated_7d", "mh_isolated_7d", compute_binary, jeffreys_binary,
360+
# wave 11
361+
"pct_worried_catch_covid", "mh_worried_catch_covid", compute_binary, jeffreys_binary,
358362

359363
# travel outside state
360364
# pre-wave 10
@@ -420,7 +424,11 @@ get_aggs <- function() {
420424
"pct_vaccine_barrier_type_tried", "v_vaccine_barrier_type_tried", compute_binary, jeffreys_binary,
421425
"pct_vaccine_barrier_none_tried", "v_vaccine_barrier_none_tried", compute_binary, jeffreys_binary,
422426
"pct_vaccine_barrier_appointment_location_tried", "v_vaccine_barrier_appointment_location_tried", compute_binary, jeffreys_binary,
423-
"pct_vaccine_barrier_other_tried", "v_vaccine_barrier_other_tried", compute_binary, jeffreys_binary
427+
"pct_vaccine_barrier_other_tried", "v_vaccine_barrier_other_tried", compute_binary, jeffreys_binary,
428+
429+
# schooling
430+
"pct_inperson_school_fulltime", "s_inperson_school_fulltime", compute_binary, jeffreys_binary,
431+
"pct_inperson_school_parttime", "s_inperson_school_parttime", compute_binary, jeffreys_binary
424432
)
425433

426434
aggs <- create_aggs_product(regions, groups, indicators)

facebook/delphiFacebook/R/contingency_variables.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,36 @@ code_behaviors <- function(input_data, wave) {
10401040
} else {
10411041
input_data$c_direct_contact <- NA
10421042
}
1043+
1044+
# avoid_contact
1045+
# Percentage of respondents that have reported having intentionally avoided
1046+
# contact with other people all or most of the time
1047+
# 1 = all of the time, 2 = most of the time, 3 = some of the time,
1048+
# 4 = none of the time
1049+
if ("C7" %in% names(input_data)) {
1050+
input_data$c_avoid_contact <- case_when(
1051+
input_data$C7 %in% c(1, 2) ~ 1,
1052+
input_data$C7 %in% c(3, 4) ~ 0,
1053+
TRUE ~ NA_real_
1054+
)
1055+
} else {
1056+
input_data$c_avoid_contact <- NA_real_
1057+
}
1058+
1059+
# avoid_contact_7d
1060+
# Percentage of respondents that have reported having intentionally avoided
1061+
# contact with other people all or most of the time in the last 7 days
1062+
# 1 = all of the time, 2 = most of the time, 3 = some of the time,
1063+
# 4 = a little of the time, 5 = none of the time
1064+
if ("C7a" %in% names(input_data)) {
1065+
input_data$c_avoid_contact_7d <- case_when(
1066+
input_data$C7a %in% c(1, 2) ~ 1,
1067+
input_data$C7a %in% c(3, 4, 5) ~ 0,
1068+
TRUE ~ NA_real_
1069+
)
1070+
} else {
1071+
input_data$c_avoid_contact_7d <- NA_real_
1072+
}
10431073

10441074
return(input_data)
10451075
}

0 commit comments

Comments
 (0)