Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. # Setting up the different possible outcomes, exposures, and covariates
  2.  
  3. ## make vector of outcomes
  4. outcomes <- c("hist_tau_avg",
  5. "hist_tau_frontal",
  6. "hist_tau_temporal",
  7. "hist_tau_parietal",
  8. "hist_AB_avg",
  9. "hist_AB_frontal",
  10. "hist_AB_temporal",
  11. "hist_AB_parietal")
  12.  
  13. ## make vector of exposures
  14. exposures <- c("pm25_avg_5", "bl_pm25_avg_5") #update with new exposures
  15.  
  16. ## make list of covariates
  17. model1 <- c("APOE", "FamHx_Dx_cat")
  18. model2 <- c(model1, "age_death_yrs")
  19. model3 <- c(model2, "degree_cat", "tr_med_inc_hshld_cat_abbrev")
  20. model4 <- c(model3, "race_cat", "marital_cat", "smoke_cat", "exercise_cat",
  21. "alcohol_cat", "cohort_cat")
  22. model5 <- c(model4, "bmi_cat","diabetes_cat", "HTN_cat", "CVD_cat")
  23. covariates_list <- list(model1 = model1,
  24. model2 = model2,
  25. model3 = model3,
  26. model4 = model4,
  27. model5 = model5)
  28.  
  29. # Trying with APOE effect modification
  30.  
  31. # Using expand.grid() is way easier than using nested loops, etc.
  32.  
  33. df <- data.frame(expand.grid(outcomes, exposures, covariates_list))
  34. names(df) <- c('outcome', 'exposure', 'covar_list')
  35. df$covariates <- sapply(df$covar_list, paste, collapse = " + ")
  36.  
  37. formula_list_APOE <- with(df, paste(outcome, '~', exposure, '+',
  38. gsub('^(\\w+).*$', '\\1', covariates), '*',
  39. exposure, '+', covariates))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement