stat_lme: Create an lme stat object.

View source: R/stat_lme.R

stat_lmeR Documentation

Create an lme stat object.

Description

This function creates an lme 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 lme function from the nlme 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_lme(
  id,
  time,
  poly = NULL,
  splines = NULL,
  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.

poly

numeric or list. Whether to use polynomial regression. Supplying a single number will call poly(..., #NUMBER#, raw=TRUE) on every covariate and predictor. Supplying a list allows you to perform a polynomial expansion on specific variables. NULL means no polynomials.

splines

numeric or vector. If this is one single value, then this will be interpreted as the number of knots ("df") whose location will be determined automatically according to the splines::ns() function. If this is a vector of values, then this will be interpreted as the location of the knots ("knots"). See the splines::ns() function for more info.

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 lme 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_lme(id = 'RID', time = 'YEARS_bl')
  ) %>%
  fit()

model_summary <- model %>% aba_summary()


ncullen93/abaR documentation built on Feb. 8, 2024, 12:01 p.m.