stat_ancova: Create an ancova stat object.

Description Usage Arguments Value Examples

View source: R/stat_ancova.R

Description

This function creates an ancova stat object which can be passed as input to the set_stats() function when building an aba model. This stat performs a traditional ancova analysis using the lm function with change in endpoint as outcome, adjustment for baseline covariates and baseline outcome, and also a treatment variable whose effect on the endpoint you care about.

Usage

1
2
3
4
5
6
stat_ancova(
  treatment,
  baseline_suffix = "bl",
  std.beta = FALSE,
  complete.cases = TRUE
)

Arguments

treatment

string. The treatment variable whose effect on the outcome you care about. If you don't have a treatment, then you can just use stat_lm with a change variable as the outcome.

baseline_suffix

string. The suffix to add to each outcome variable in order to pick up the associated baseline variable. You must adjust for the baseline outcome in ancova, and there is no other way to specify a different predictor for each outcome. So if the outcomes are e.g. "CDRSB" and "MMSE", then a baseline_suffix of "bl" will mean that each ancova fit with "CDRSB" as outcome will have "CDRSB_bl" added to the formula and every fit with "MMSE" as outcome will have "MMSE_bl" added. This means that these baseline variables must actually exist in the data!

std.beta

logical. Whether to standardize model predictors and covariates prior to analysis.

complete.cases

logical. Whether to only include the subset of data with no missing data for any of the outcomes, predictors, or covariates. Note that complete cases are considering within each group - outcome combination but across all predictor sets.

Value

An abaStat object with ancova stat type.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# filter to 24 month visit; calculate change in cognition to use as outcome;
# assume abeta status as "treatment" variable.
# The goal is to see if "treatment" has an effect on 2y cognitive decline
data <- adnimerge %>%
  dplyr::filter(
    VISCODE == 'm24',
    DX_bl %in% c('MCI', 'AD'),
    !is.na(CSF_ABETA_STATUS_bl)
  ) %>%
  dplyr::mutate(
    CDRSB = CDRSB - CDRSB_bl,
    ADAS13 = ADAS13 - ADAS13_bl,
    TREATMENT = factor(CSF_ABETA_STATUS_bl, levels=c(1,0),
                       labels=c('Placebo','Treatment'))
  )

# fit model. note that baseline outcome will be added based on the suffix.
# e.g., fits with "CDRSB" as outcome will also add "CDRSB_bl" to the formula.
ancova_model <- data %>% aba_model() %>%
  set_outcomes(CDRSB, ADAS13) %>%
  set_covariates(AGE, GENDER, EDUCATION) %>%
  set_stats(
    stat_ancova(treatment = 'TREATMENT', baseline_suffix = 'bl')
  ) %>%
  fit()

# summarise model. treatment effect will be shown in the treatment coefficient
ancova_summary <- ancova_model %>% summary()

aba documentation built on Dec. 17, 2021, 1:06 a.m.