set_groups: Set the groups of an aba model.

Description Usage Arguments Details Value Examples

View source: R/aba_utils.R

Description

Groups are the filtered subsets of data which you want to fit statistical models on. This function supports both string inputs and logical functions of variables (provided that the data is already set for the aba model). The inputs should be separated by a comma, where each input is a different group. You can also specify labels for each group.

Usage

1
set_groups(object, ..., labels = NULL)

Arguments

object

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

...

comma-separated strings or logical expressions. This specifies the subsets of the data by which the aba model will filter.

labels

vector of strings. Optional labels for printing & plotting.

Details

Note that everyone() or "everyone()" can be used to specify a group with no filtering. This can be useful when you want to fit models on the entire group and on a sub-group.

Value

An aba model with groups set to the given input.

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
data <- adnimerge %>% dplyr::filter(VISCODE == 'bl')

# set groups based on logical expressions. Here, data must be supplied first.
model <- data %>% aba_model() %>%
  set_groups(
    everyone(),
    DX_bl == 'CU',
    (DX_bl %in% c('MCI','AD')) & (CSF_ABETA_bl < 880)
  )
print(model)

# specify labels which will be used later for printing & plotting
model <- data %>% aba_model() %>%
  set_groups(
    everyone(),
    DX_bl == 'CU',
    (DX_bl %in% c('MCI','AD')) & (CSF_ABETA_bl < 880),
    labels = c('All participants', 'CU-only', 'Ab+ MCI & AD')
  )
print(model)

# set groups based on strings. No data is required to be supplied first.
model <- aba_model() %>%
  set_groups(
    "everyone()",
    "DX_bl == 'CU'",
    "(DX_bl %in% c('MCI','AD')) & (CSF_ABETA_bl < 880)"
  )
print(model)

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