Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Setting up the different possible outcomes, exposures, and covariates
- ## make vector of outcomes
- outcomes <- c("hist_tau_avg",
- "hist_tau_frontal",
- "hist_tau_temporal",
- "hist_tau_parietal",
- "hist_AB_avg",
- "hist_AB_frontal",
- "hist_AB_temporal",
- "hist_AB_parietal")
- ## make vector of exposures
- exposures <- c("pm25_avg_5", "bl_pm25_avg_5") #update with new exposures
- ## make list of covariates
- model1 <- c("APOE", "FamHx_Dx_cat")
- model2 <- c(model1, "age_death_yrs")
- model3 <- c(model2, "degree_cat", "tr_med_inc_hshld_cat_abbrev")
- model4 <- c(model3, "race_cat", "marital_cat", "smoke_cat", "exercise_cat",
- "alcohol_cat", "cohort_cat")
- model5 <- c(model4, "bmi_cat","diabetes_cat", "HTN_cat", "CVD_cat")
- covariates_list <- list(model1 = model1,
- model2 = model2,
- model3 = model3,
- model4 = model4,
- model5 = model5)
- # Trying with APOE effect modification
- # Using expand.grid() is way easier than using nested loops, etc.
- df <- data.frame(expand.grid(outcomes, exposures, covariates_list))
- names(df) <- c('outcome', 'exposure', 'covar_list')
- df$covariates <- sapply(df$covar_list, paste, collapse = " + ")
- formula_list_APOE <- with(df, paste(outcome, '~', exposure, '+',
- gsub('^(\\w+).*$', '\\1', covariates), '*',
- exposure, '+', covariates))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement