predict.abaModel: Get individual predictions from a fitted aba model

View source: R/aba_predict.R

predict.abaModelR Documentation

Get individual predictions from a fitted aba model

Description

This function allows you to get the fitted/predicted values from data used to fit an aba model or from new data. This is essentially an extension of the broom::augment() function.

Usage

## S3 method for class 'abaModel'
predict(object, ...)

Arguments

object

a fitted aba model. The model to get predictions from.

...

additional parameters. Accepted: newdata, merge, augment. See aba_fit() for more information.

Value

a dataframe with original data and with fitted/predicted values added for each group-outcome-stat-predictor combination.

Examples

data <- adnimerge %>% dplyr::filter(VISCODE == 'bl')

model <- data %>% aba_model() %>%
  set_groups(
    everyone(),
    DX_bl %in% c('MCI', 'AD')
  ) %>%
  set_outcomes(CDRSB_bl, MMSE_bl) %>%
  set_predictors(
    PLASMA_PTAU181_bl, PLASMA_NFL_bl,
    c(PLASMA_PTAU181_bl, PLASMA_NFL_bl)
  ) %>%
  set_covariates(AGE, GENDER, EDUCATION) %>%
  set_stats('lm')

model <- model %>% fit()

# add model predictions to original data
data_augmented <- model %>% aba_predict()

# store predictions separately by group - outcome - stat combination
data_augmented2 <- model %>% aba_predict(merge = FALSE)

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