The multi-year weight is typically the 2-year weight divided by the number of cycles being combined.
The Adjustment Models Framework
nhanespewas provides 9 standard adjustment scenarios via adjustment_models:
# View all adjustment modelsadjustment_models
Adjustment Model Details
Model
Covariates
1
Unadjusted (exposure only)
2
Age, sex
3
Age, sex, race/ethnicity
4
Age, sex, race/ethnicity, income
5
Age, sex, race/ethnicity, income, BMI
6
Age, sex, race/ethnicity, income, smoking
7
Age, sex, race/ethnicity, income, BMI, smoking
8
Age, sex, race/ethnicity, income + urinary creatinine
9
Age, sex, race/ethnicity, income + dietary variables
Examining a Specific Adjustment Model
# Model 4: age, sex, race, income (our standard model)adjustment_models[[4]]
# List the covariate names for each modellapply(adjustment_models, function(x) x$covariates)
pe_flex_adjust(): The Core Function
pe_flex_adjust() runs a single phenotype-exposure association with flexible adjustment:
pe_flex_adjust( phenotype, # phenotype variable name (string) exposure, # exposure variable name (string) adjustment_model, # which adjustment model to use con, # database connection ...)
# Run the same association with different adjustment levelsresults_by_adj <-map(1:4, function(i) {pe_flex_adjust(phenotype ="BMXBMI",exposure ="LBXBPB",adjustment_model = adjustment_models[[i]],con = con )})
Sensitivity to Adjustment
# Compare the lead coefficient across adjustment modelssensitivity <-map_dfr(1:4, function(i) { results_by_adj[[i]] %>%map_dfr(~tidy(.), .id ="cycle") %>%filter(grepl("LBXBPB", term)) %>%mutate(adj_model = i)})sensitivity %>%select(adj_model, cycle, estimate, p.value) %>%kable(digits =4) %>%kable_styling(font_size =9)
Checking Exposure Data Type
Before running an ExWAS, check whether each exposure is continuous or categorical:
# Check data type of an exposurecheck_e_data_type("LBXBPB", con) # continuouscheck_e_data_type("SMQ020", con) # categorical (smoking status)
This determines whether to use linear regression (continuous) or treat the exposure as a factor.
Working with Categorical Exposures
For categorical exposures, the package handles factor encoding: