aba_emmeans: Calculated estimated marginal means.

Description Usage Arguments Details Value Examples

View source: R/aba_emmeans.R

Description

This function estimates the estimated marginal means (also known as least-square means) and, if relevant, the treatment effects for mmrm, lme, and ancova models.

Usage

1
aba_emmeans(model)

Arguments

model

abaModel. The fitted aba model to run emmeans on.

Details

This function is based on the emmeans::emmeans function. This function will only be run for the stats which are supported by emmeans.

Value

an abaEmmeans object. This object contains the emmeans, the paired comparisons (i.e., treatment effect), and the sample size at each visit.

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
29
30
# process data: take first 4 visits, only MCI, use CSF abeta as "treatment",
# and create endpoint as change from baseline in cognition at each visit
df <- adnimerge %>%
  dplyr::filter(
    VISCODE %in% c('bl','m06','m12','m24'),
    !is.na(CSF_ABETA_STATUS_bl),
    DX_bl %in% c('MCI')
  ) %>%
  dplyr::mutate(
    TREATMENT = factor(CSF_ABETA_STATUS_bl, levels=c(0,1),
                       labels=c('Placebo','Treatment')),
    ADAS13 = ADAS13 - ADAS13_bl,
    CDRSB = CDRSB - CDRSB_bl,
    MMSE = MMSE - MMSE_bl
  )

# fit mmrm model for different endpoints, adjusted for covariates
model <- df %>% aba_model() %>%
  set_outcomes(CDRSB, ADAS13, MMSE) %>%
  set_covariates(
    AGE, GENDER, EDUCATION
  ) %>%
  set_stats(
    stat_mmrm(id = 'RID', time = 'VISCODE', treatment = 'TREATMENT')
  ) %>%
  aba_fit()

# run emmeans

model_emmeans <- model %>% aba_emmeans()

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