Skip to content

Commit af5afb4

Browse files
committed
Add confidence interval as parameter. Create interaction between PA and AP for confidence interval columns. If they don't exist, use the median column. Re #94
1 parent 6fdb29e commit af5afb4

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

R/combined_rr_ap_pa.R

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
#'
55
#' @param ind_pa data frame of individual RRs for diseases affected by PA
66
#' @param ind_ap data frame of individual RRs for diseases affected by AP
7+
#' @param conf_int logic: whether to include confidence interval from dose response relationships or not
78
#'
89
#' @return combined RR for diseases after accounted for AP and PA exposures
910
#'
1011
#' @export
11-
combined_rr_ap_pa <- function(ind_pa,ind_ap){
12+
combined_rr_ap_pa <- function(ind_pa, ind_ap, conf_int = FALSE){
1213

1314
# Replace NaNs with 1
1415
ind_ap[is.na(ind_ap)] <- 1
@@ -24,6 +25,20 @@ combined_rr_ap_pa <- function(ind_pa,ind_ap){
2425
ac <- as.character(DISEASE_INVENTORY$acronym[j])
2526
for (scen in SCEN_SHORT_NAME){
2627
ind_ap_pa[[paste('RR_pa_ap', scen, ac, sep = '_')]] <- ind_ap_pa[[paste('RR_pa', scen, ac, sep = '_')]] * ind_ap_pa[[paste('RR_ap', scen, ac, sep = '_')]]
28+
29+
if (conf_int){
30+
column_pa_lb <- ifelse(paste('RR_pa', scen, ac, 'lb', sep = '_') %in% colnames(ind_ap_pa), paste('RR_pa', scen, ac, 'lb', sep = '_'), paste('RR_pa', scen, ac, sep = '_'))
31+
column_pa_ub <- ifelse(paste('RR_pa', scen, ac, 'ub', sep = '_') %in% colnames(ind_ap_pa), paste('RR_pa', scen, ac, 'ub', sep = '_'), paste('RR_pa', scen, ac, sep = '_'))
32+
33+
column_ap_lb <- ifelse(paste('RR_ap', scen, ac, 'lb', sep = '_') %in% colnames(ind_ap_pa), paste('RR_ap', scen, ac, 'lb', sep = '_'), paste('RR_ap', scen, ac, sep = '_'))
34+
column_ap_ub <- ifelse(paste('RR_ap', scen, ac, 'ub', sep = '_') %in% colnames(ind_ap_pa), paste('RR_ap', scen, ac, 'ub', sep = '_'), paste('RR_ap', scen, ac, sep = '_'))
35+
36+
37+
ind_ap_pa[[paste('RR_pa_ap', scen, ac, 'lb', sep = '_')]] <- ind_ap_pa[[column_pa_lb]] * ind_ap_pa[[column_ap_lb]]
38+
39+
ind_ap_pa[[paste('RR_pa_ap', scen, ac, 'ub', sep = '_')]] <- ind_ap_pa[[column_pa_ub]] * ind_ap_pa[[column_ap_ub]]
40+
41+
}
2742
}
2843
}
2944

0 commit comments

Comments
 (0)