Skip to contents

This function creates an lmer stat object which can be passed as input to the set_stats() function when building an aba model. This stat performs a linear mixed effects model analysis using the lmer function from the nlmer package. Please note that the default mode is to include an interaction term between the time variable and each predictor - i.e., time*predictor will be in the model formula - but this does not happen for covariates. Also, this model fits random intercepts and random slopes. The data for this model should be in long format with one row per subject-visit.

Usage

stat_lmer(id, time, std.beta = FALSE, complete.cases = TRUE)

Arguments

id

string. This is the variable in the data which represents the subject id to be used for random intercepts and random slopes.

time

string. This is the time variable in the data which represents the time from baseline that the visit occured.

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 lmer stat type.

Examples


data <- adnimerge %>%
  dplyr::filter(VISCODE %in% c('bl','m06','m12','m24'))

model <- data %>% aba_model() %>%
  set_groups(
    everyone(),
    DX_bl %in% c('MCI', 'AD')
  ) %>%
  set_outcomes(CDRSB, ADAS13) %>%
  set_predictors(
    PLASMA_ABETA_bl,
    PLASMA_PTAU181_bl,
    PLASMA_NFL_bl,
    c(PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl)
  ) %>%
  set_covariates(AGE, GENDER, EDUCATION) %>%
  set_stats(
    stat_lmer(id = 'RID', time = 'YEARS_bl')
  ) %>%
  fit()
#> Warning: There were 20 warnings in `mutate()`.
#> The first warning was:
#>  In argument: `fit = fit_stat(...)`.
#>  In row 1.
#> Caused by warning in `value[[3L]]()`:
#> ! Problem fitting model:
#> CDRSB ~ YEARS_bl + AGE + GENDER + EDUCATION + (YEARS_bl | RID)
#> Check your variables for collinearity or missingness.
#> Skipping for now...
#>  Run `dplyr::last_dplyr_warnings()` to see the 19 remaining warnings.
#> Error in fit_standard(., verbose = verbose): All models failed to be fit. Check your model setup.

model_summary <- model %>% aba_summary()
#> Error in eval(expr, envir, enclos): object 'model' not found