# NOT RUN {
# use built-in data and only take the baseline visit
data <- adnimerge %>% dplyr::filter(VISCODE == 'bl')
# Create aba model w/ data, groups, outcomes, covariates, predictors, stats.
# Note that we start with piping the data into the aba_model... This is
# possible because `data` is the first argument of the `aba_model()` function
# and is useful because it gives auto-completion of variables names in Rstudio.
model <- data %>% aba_model() %>%
set_groups(everyone(), DX_bl %in% c('MCI','AD')) %>%
set_outcomes(ConvertedToAlzheimers, CSF_ABETA_STATUS_bl) %>%
set_covariates(AGE, GENDER, EDUCATION) %>%
set_predictors(
PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl,
c(PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl)
) %>%
set_stats('glm')
# get a useful view of the model spec:
print(model)
# model specs can be modified to build on one another and save time when
# doing sensitivity analyses. Here, we create the same model as before but
# just add APOE4 as covariate.
model2 <- model %>%
set_covariates(AGE, GENDER, EDUCATION, APOE4)
# see this change in the model print
print(model2)
# Calling the `fit()` function actually triggers fitting of statistics.
model <- model %>% fit()
model2 <- model2 %>% fit()
# Access the raw results in case you care about that:
print(model$results)
# Calling the `summary()` function summarises covariates and metrics in
# a useful manner
model_summary <- model %>% summary()
model2_summary <- model2 %>% summary()
# see a nicely formatted print out of the summary
print(model_summary)
# or access the raw summary results:
print(model_summary$results)
# }
Run the code above in your browser using DataLab