Skip to content

Commit 08d2c2f

Browse files
authored
Merge pull request #1695 from cmu-delphi/ndefries/final-contingency-fixes
[CTIS] Add a few missing indicators and wave-specific handling for multi-selects
2 parents 2ec8921 + ed6e733 commit 08d2c2f

File tree

3 files changed

+110
-18
lines changed

3 files changed

+110
-18
lines changed

facebook/delphiFacebook/R/contingency_indicators.R

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ THEME_GROUPS <- list(
170170
"pct_hesitant_dontneed_reason_not_serious",
171171
"pct_hesitant_dontneed_reason_other",
172172
"pct_hesitant_dontneed_reason_precautions",
173+
"pct_barrier_reason_dontneed_had_covid",
174+
"pct_barrier_reason_dontneed_dont_spend_time",
175+
"pct_barrier_reason_dontneed_not_high_risk",
176+
"pct_barrier_reason_dontneed_precautions",
177+
"pct_barrier_reason_dontneed_not_serious",
178+
"pct_barrier_reason_dontneed_not_beneficial",
179+
"pct_barrier_reason_dontneed_other",
173180
"pct_hesitant_trust_covid_info_cdc",
174181
"pct_hesitant_trust_covid_info_doctors",
175182
"pct_hesitant_trust_covid_info_experts",
@@ -388,15 +395,16 @@ THEME_GROUPS <- list(
388395
"pct_unusual_symptom_sleep_changes",
389396
"pct_unusual_symptom_stuffy_nose",
390397
"pct_unusual_symptom_other",
391-
"pct_unusual_symptom_hospital",
392-
"pct_unusual_symptom_hospital_tried",
398+
"pct_symptom_hospital",
399+
"pct_symptom_hospital_tried",
393400
"pct_unusual_symptom_medical_care_called_doctor",
394401
"pct_unusual_symptom_medical_care_telemedicine",
395402
"pct_unusual_symptom_medical_care_visited_doctor",
396403
"pct_unusual_symptom_medical_care_urgent_care",
397404
"pct_unusual_symptom_medical_care_er",
398405
"pct_unusual_symptom_medical_care_hospital",
399406
"pct_unusual_symptom_medical_care_tried",
407+
"pct_unusual_symptom_medical_care_none",
400408
"pct_unusual_symptom_tested",
401409
"pct_unusual_symptom_tested_positive"
402410
),
@@ -720,6 +728,19 @@ get_aggs <- function() {
720728
"pct_unusual_symptom_stuffy_nose", "symp_stuffy_nose_unusual", compute_binary, jeffreys_binary,
721729
"pct_unusual_symptom_other", "symp_other_unusual", compute_binary, jeffreys_binary,
722730

731+
# symptom followup medical care
732+
"pct_symptom_hospital", "t_symptom_hospital", compute_binary, jeffreys_binary,
733+
"pct_symptom_hospital_tried", "t_symptom_hospital_tried", compute_binary, jeffreys_binary,
734+
735+
"pct_unusual_symptom_medical_care_called_doctor", "unusual_symptom_medical_care_called_doctor", compute_binary, jeffreys_binary,
736+
"pct_unusual_symptom_medical_care_telemedicine", "unusual_symptom_medical_care_telemedicine", compute_binary, jeffreys_binary,
737+
"pct_unusual_symptom_medical_care_visited_doctor", "unusual_symptom_medical_care_visited_doctor", compute_binary, jeffreys_binary,
738+
"pct_unusual_symptom_medical_care_urgent_care", "unusual_symptom_medical_care_urgent_care", compute_binary, jeffreys_binary,
739+
"pct_unusual_symptom_medical_care_er", "unusual_symptom_medical_care_er", compute_binary, jeffreys_binary,
740+
"pct_unusual_symptom_medical_care_hospital", "unusual_symptom_medical_care_hospital", compute_binary, jeffreys_binary,
741+
"pct_unusual_symptom_medical_care_tried", "unusual_symptom_medical_care_tried", compute_binary, jeffreys_binary,
742+
"pct_unusual_symptom_medical_care_none", "unusual_symptom_medical_care_none", compute_binary, jeffreys_binary,
743+
723744
# vaccines
724745
"pct_vaccinated", "v_covid_vaccinated", compute_binary, jeffreys_binary,
725746
"pct_received_2_vaccine_doses", "v_received_2_vaccine_doses", compute_binary, jeffreys_binary,
@@ -847,6 +868,14 @@ get_aggs <- function() {
847868
"pct_hesitant_dontneed_reason_not_beneficial", "v_hesitant_dontneed_reason_not_beneficial", compute_binary, jeffreys_binary,
848869
"pct_hesitant_dontneed_reason_other", "v_hesitant_dontneed_reason_other", compute_binary, jeffreys_binary,
849870

871+
"pct_barrier_reason_dontneed_had_covid", "v_dontneed_reason_had_covid", compute_binary, jeffreys_binary,
872+
"pct_barrier_reason_dontneed_dont_spend_time", "v_dontneed_reason_dont_spend_time", compute_binary, jeffreys_binary,
873+
"pct_barrier_reason_dontneed_not_high_risk", "v_dontneed_reason_not_high_risk", compute_binary, jeffreys_binary,
874+
"pct_barrier_reason_dontneed_precautions", "v_dontneed_reason_precautions", compute_binary, jeffreys_binary,
875+
"pct_barrier_reason_dontneed_not_serious", "v_dontneed_reason_not_serious", compute_binary, jeffreys_binary,
876+
"pct_barrier_reason_dontneed_not_beneficial", "v_dontneed_reason_not_beneficial", compute_binary, jeffreys_binary,
877+
"pct_barrier_reason_dontneed_other", "v_dontneed_reason_other", compute_binary, jeffreys_binary,
878+
850879
"pct_barrier_sideeffects", "v_hesitancy_reason_sideeffects", compute_binary, jeffreys_binary,
851880
"pct_barrier_allergic", "v_hesitancy_reason_allergic", compute_binary, jeffreys_binary,
852881
"pct_barrier_ineffective", "v_hesitancy_reason_ineffective", compute_binary, jeffreys_binary,
@@ -1001,16 +1030,6 @@ get_aggs <- function() {
10011030

10021031
"pct_unusual_symptom_tested", "t_unusual_symptom_tested", compute_binary, jeffreys_binary,
10031032
"pct_unusual_symptom_tested_positive", "t_unusual_symptom_tested_positive", compute_binary, jeffreys_binary,
1004-
"pct_unusual_symptom_hospital", "t_unusual_symptom_hospital", compute_binary, jeffreys_binary,
1005-
"pct_unusual_symptom_hospital_tried", "t_unusual_symptom_hospital_tried", compute_binary, jeffreys_binary,
1006-
1007-
"pct_unusual_symptom_medical_care_called_doctor", "unusual_symptom_medical_care_called_doctor", compute_binary, jeffreys_binary,
1008-
"pct_unusual_symptom_medical_care_telemedicine", "unusual_symptom_medical_care_telemedicine", compute_binary, jeffreys_binary,
1009-
"pct_unusual_symptom_medical_care_visited_doctor", "unusual_symptom_medical_care_visited_doctor", compute_binary, jeffreys_binary,
1010-
"pct_unusual_symptom_medical_care_urgent_care", "unusual_symptom_medical_care_urgent_care", compute_binary, jeffreys_binary,
1011-
"pct_unusual_symptom_medical_care_er", "unusual_symptom_medical_care_er", compute_binary, jeffreys_binary,
1012-
"pct_unusual_symptom_medical_care_hospital", "unusual_symptom_medical_care_hospital", compute_binary, jeffreys_binary,
1013-
"pct_unusual_symptom_medical_care_tried", "unusual_symptom_medical_care_tried", compute_binary, jeffreys_binary,
10141033

10151034
"pct_reason_not_tested_tried", "t_reason_not_tested_tried", compute_binary, jeffreys_binary,
10161035
"pct_reason_not_tested_appointment", "t_reason_not_tested_appointment", compute_binary, jeffreys_binary,

facebook/delphiFacebook/R/contingency_variables.R

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ code_health <- function(input_data, wave) {
165165
input_data$comorbidobese <- is_selected(comorbidities, "13")
166166
input_data$comorbid_none <- is_selected(comorbidities, "9")
167167

168+
if (wave < 4) {
169+
# Added in Wave 4
170+
input_data$comorbidimmuno <- NA
171+
}
172+
if (wave < 8) {
173+
# Added in Wave 8
174+
input_data$comorbidobese <- NA
175+
}
176+
if (wave >= 11) {
177+
# Removed in Wave 11
178+
input_data$comorbid_autoimmune <- NA
179+
}
180+
168181
# Combo vaccine-eligibility
169182
input_data$eligible <-
170183
input_data$comorbidheartdisease |
@@ -367,11 +380,11 @@ code_addl_vaccines <- function(input_data, wave) {
367380
}
368381

369382
if ("B6" %in% names(input_data)) {
370-
input_data$t_unusual_symptom_hospital <- input_data$B6 == 1
371-
input_data$t_unusual_symptom_hospital_tried <- input_data$B6 == 1 | input_data$B6 == 3
383+
input_data$t_symptom_hospital <- input_data$B6 == 1
384+
input_data$t_symptom_hospital_tried <- input_data$B6 == 1 | input_data$B6 == 3
372385
} else {
373-
input_data$t_unusual_symptom_hospital <- NA
374-
input_data$t_unusual_symptom_hospital_tried <- NA
386+
input_data$t_symptom_hospital <- NA
387+
input_data$t_symptom_hospital_tried <- NA
375388
}
376389

377390
if ("B7" %in% names(input_data) && wave != 10) {
@@ -392,6 +405,7 @@ code_addl_vaccines <- function(input_data, wave) {
392405
input_data$unusual_symptom_medical_care_er <- is_selected(unusual_symptoms_care, "5")
393406
input_data$unusual_symptom_medical_care_hospital <- is_selected(unusual_symptoms_care, "6")
394407
input_data$unusual_symptom_medical_care_tried <- is_selected(unusual_symptoms_care, "7")
408+
input_data$unusual_symptom_medical_care_none <- is_selected(unusual_symptoms_care, "8")
395409
} else {
396410
input_data$unusual_symptom_medical_care_called_doctor <- NA
397411
input_data$unusual_symptom_medical_care_telemedicine <- NA
@@ -400,6 +414,7 @@ code_addl_vaccines <- function(input_data, wave) {
400414
input_data$unusual_symptom_medical_care_er <- NA
401415
input_data$unusual_symptom_medical_care_hospital <- NA
402416
input_data$unusual_symptom_medical_care_tried <- NA
417+
input_data$unusual_symptom_medical_care_none <- NA
403418
}
404419

405420
if ( "B12a" %in% names(input_data) ) {
@@ -1154,6 +1169,32 @@ code_addl_symptoms <- function(input_data, wave) {
11541169
input_data$symp_headache <- is_selected(symptoms, "18")
11551170
input_data$symp_sleep_changes <- is_selected(symptoms, "19")
11561171
input_data$symp_stuffy_nose <- is_selected(symptoms, "20")
1172+
1173+
if (wave < 3) {
1174+
# Added in Wave 3
1175+
input_data$symp_eye_pain <- NA
1176+
}
1177+
if (wave < 4) {
1178+
# Added in Wave 4
1179+
input_data$symp_chills <- NA
1180+
}
1181+
if (wave < 5) {
1182+
# Added in Wave 5
1183+
input_data$symp_headache <- NA
1184+
input_data$symp_sleep_changes <- NA
1185+
}
1186+
if (wave < 11) {
1187+
# Added in Wave 11
1188+
input_data$symp_stuffy_nose <- NA
1189+
}
1190+
if (wave >= 11) {
1191+
# All removed in Wave 11
1192+
input_data$symp_nasal_congestion <- NA
1193+
input_data$symp_runny_nose <- NA
1194+
input_data$symp_eye_pain <- NA
1195+
input_data$symp_sleep_changes <- NA
1196+
}
1197+
11571198
} else {
11581199
input_data$symp_fever <- NA
11591200
input_data$symp_cough <- NA
@@ -1265,6 +1306,33 @@ code_addl_symptoms <- function(input_data, wave) {
12651306
input_data$symp_unusual_given_stuffy_nose <- calc_unusual_given_symptom(
12661307
input_data$symp_stuffy_nose, is_selected(symptoms, "20")
12671308
)
1309+
1310+
if (wave < 5) {
1311+
# Added in Wave 5
1312+
input_data$symp_headache_unusual <- NA
1313+
input_data$symp_sleep_changes_unusual <- NA
1314+
1315+
input_data$symp_unusual_given_headache <- NA
1316+
input_data$symp_unusual_given_sleep_changes <- NA
1317+
}
1318+
if (wave < 11) {
1319+
# Added in Wave 11
1320+
input_data$symp_stuffy_nose_unusual <- NA
1321+
1322+
input_data$symp_unusual_given_stuffy_nose <- NA
1323+
}
1324+
if (wave >= 11) {
1325+
# All removed in Wave 11
1326+
input_data$symp_nasal_congestion_unusual <- NA
1327+
input_data$symp_runny_nose_unusual <- NA
1328+
input_data$symp_eye_pain_unusual <- NA
1329+
input_data$symp_sleep_changes_unusual <- NA
1330+
1331+
input_data$symp_unusual_given_nasal_congestion <- NA
1332+
input_data$symp_unusual_given_runny_nose <- NA
1333+
input_data$symp_unusual_given_eye_pain <- NA
1334+
input_data$symp_unusual_given_sleep_changes <- NA
1335+
}
12681336
} else {
12691337
input_data$symp_unusual_given_fever <- NA
12701338
input_data$symp_unusual_given_cough <- NA
@@ -1658,15 +1726,15 @@ code_addl_demographic <- function(input_data, wave) {
16581726
input_data$language_home_chinese <- input_data$D12 == 3
16591727
input_data$language_home_vietnamese <- input_data$D12 == 4
16601728
input_data$language_home_french <- input_data$D12 == 5
1661-
input_data$language_home_portugese <- input_data$D12 == 6
1729+
input_data$language_home_portuguese <- input_data$D12 == 6
16621730
input_data$language_home_other <- input_data$D12 == 7
16631731
} else {
16641732
input_data$language_home_english <- NA
16651733
input_data$language_home_spanish <- NA
16661734
input_data$language_home_chinese <- NA
16671735
input_data$language_home_vietnamese <- NA
16681736
input_data$language_home_french <- NA
1669-
input_data$language_home_portugese <- NA
1737+
input_data$language_home_portuguese <- NA
16701738
input_data$language_home_other <- NA
16711739
}
16721740

facebook/delphiFacebook/R/variables.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,11 @@ code_testing <- function(input_data, wave) {
428428
input_data$t_tested_reason_other <- is_selected(testing_reasons, "8")
429429
input_data$t_tested_reason_travel <- is_selected(testing_reasons, "9")
430430

431+
432+
if (wave < 11) {
433+
# Added in Wave 11
434+
input_data$t_tested_reason_travel <- NA
435+
}
431436
if (wave >= 11) {
432437
input_data$t_tested_reason_large_event <- NA
433438
input_data$t_tested_reason_crowd <- NA

0 commit comments

Comments
 (0)