aba_model: Create an aba model.

Description Usage Arguments Value Examples

View source: R/aba_model.R

Description

An aba model is the foundational object in the aba package. It is composed of the following:

Usage

1
2
3
4
5
6
7
8
9
aba_model(
  data = NULL,
  groups = NULL,
  outcomes = NULL,
  predictors = NULL,
  covariates = NULL,
  stats = NULL,
  verbose = FALSE
)

Arguments

data

data.frame the data to use for the object

groups

vector or list of logical statements as trings. Groups are subsets of the data on which different models will be fit.

outcomes

vector or list of strings Outcomes are the dependent variables in the statistical fits.

predictors

vector or list of strings Predictors are independent variables which you want to vary. You can include variables on their own or in combination with others. A collection of variables is referred to as a predictor and unique variables are referred to as a term.

covariates

vector of strings Covariates are independent variables which remain fixed across all statistical fits and are therefore always included with the different combinations of predictors.

stats

string or abaStat object(s) with stat_ prefix. Stats are the actual statistical models which you want to fit on the data. Their primary functions are to 1) generate a suitable model formula given the outcome - covariate - predictor combination, and 2) to actually fit the statistical model.

verbose

logical. Whether to give a progress bar during model fitting. This can be useful if the fitting procedure is going to take a long time.

Value

An aba model which can be fitted using the aba_fit() function and which can be modified in any manner.

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
38
39
40
41
42
43
44
45
46
# use built-in data and only take the baseline visit
data <- adnimerge %>% dplyr::filter(VISCODE == 'bl')

# Create aba model w/ data, groups, outcomes, covariates, predictors, stats.
# Note that we start with piping the data into the aba_model... This is
# possible because `data` is the first argument of the `aba_model()` function
# and is useful because it gives auto-completion of variables names in Rstudio.
model <- data %>% aba_model() %>%
  set_groups(everyone(), DX_bl %in% c('MCI','AD')) %>%
  set_outcomes(ConvertedToAlzheimers, CSF_ABETA_STATUS_bl) %>%
  set_covariates(AGE, GENDER, EDUCATION) %>%
  set_predictors(
    PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl,
    c(PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl)
  ) %>%
  set_stats('glm')

# get a useful view of the model spec:
print(model)

# model specs can be modified to build on one another and save time when
# doing sensitivity analyses. Here, we create the same model as before but
# just add APOE4 as covariate.
model2 <- model %>%
  set_covariates(AGE, GENDER, EDUCATION, APOE4)

# see this change in the model print
print(model2)

# Calling the `fit()` function actually triggers fitting of statistics.
model <- model %>% fit()
model2 <- model2 %>% fit()

# Access the raw results in case you care about that:
print(model$results)

# Calling the `summary()` function summarises covariates and metrics in
# a useful manner
model_summary <- model %>% summary()
model2_summary <- model2 %>% summary()

# see a nicely formatted print out of the summary
print(model_summary)

# or access the raw summary results:
print(model_summary$results)

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