set_predictors: Set the predictors of an aba model.

Description Usage Arguments Value Examples

View source: R/aba_utils.R

Description

Predictors are the independent variables which you want to vary as a factor in your statistical models across different groups, outcomes, and stats. Predictors can be supplied as individual variables or as collections of variables, so we refer to a unit of predictors as a "predictor". This function supports both string inputs and actual variables. This function also supports tidy-selection functions like contains and starts_with which allows convenient selection of many variables at once with common names.

Usage

1

Arguments

object

An aba model. The model for which you want to set predictors

...

strings or variables or tidy-selection functions. Each comma-separated value will be a new predictor set. If you supply actual variables, then the data of the aba model should already be set.

labels

vector of strings. Optional labels for printing & plotting.

Value

An aba model with predictors set.

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
31
32
33
34
35
36
37
data <- adnimerge %>% dplyr::filter(VISCODE == 'bl')

# set with variables - this will result in four "predictor sets".
model <- aba_model() %>%
  set_data(data) %>%
  set_predictors(
    PLASMA_ABETA_bl,
    PLASMA_PTAU181_bl,
    PLASMA_NFL_bl,
    c(PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl)
  )

# set with tidy selection functions - but this is only one "predictor set",
# not multiple individual predictor sets.
model <- aba_model() %>%
  set_data(data) %>%
  set_predictors(
    starts_with('PLASMA')
  )

# automatically generate all possible combinations of variables
model <- aba_model() %>%
  set_data(data) %>%
  set_predictors(
    all_combos(c('PLASMA_ABETA_bl', 'PLASMA_PTAU181_bl', 'PLASMA_NFL_bl'))
  )

# supply strings - data does not need to be set first here. But it will
# result in an error if these variables do not éxist in the eventual data.
model <- aba_model() %>%
  set_data(data) %>%
  set_predictors(
    'PLASMA_ABETA_bl',
    'PLASMA_PTAU181_bl',
    'PLASMA_NFL_bl',
    c('PLASMA_ABETA_bl', 'PLASMA_PTAU181_bl', 'PLASMA_NFL_bl')
  )

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