Create a demographics table from a fitted aba model.
Source:R/aba_demographics.R
aba_demographics.Rd
This function allows you to automatically create a demographics table from a fitted aba model. The variables in the table will be inferred from the spec of the model (predictors, covariates, outcomes, etc.), although this can be customized.
Usage
aba_demographics(
model,
strata = NULL,
include_predictors = TRUE,
include_covariates = TRUE,
include_outcomes = TRUE,
add_vars = NULL,
data_filter = NULL
)
Arguments
- model
abaModel. The fitted aba model to create demographics table from.
- strata
string (optional). How to stratify the demographics table.
- include_predictors
boolean. Whether to include predictors in table.
- include_covariates
boolean. Whether to include covariates in table.
- include_outcomes
boolean. Whether to include outcomes in table.
- add_vars
character vector (optional). Any additional variables to add to the demographics table. These variables should be present in the data from the aba model.
- data_filter
logical expression (optional). If this is specified, the data from the aba model will be further filtered before the table is made.
Examples
model <- aba_model() %>%
set_data(adnimerge %>% dplyr::filter(VISCODE == 'bl')) %>%
set_groups(everyone()) %>%
set_outcomes(ConvertedToAlzheimers, CSF_ABETA_STATUS_bl) %>%
set_predictors(
PLASMA_PTAU181_bl, PLASMA_NFL_bl,
c(PLASMA_PTAU181_bl, PLASMA_NFL_bl)
) %>%
set_covariates(AGE, GENDER, EDUCATION) %>%
set_stats('glm') %>%
aba_fit()
#> [1] "ConvertedToAlzheimers ~ AGE + GENDER + EDUCATION"
#> [1] "ConvertedToAlzheimers ~ AGE + GENDER + EDUCATION + PLASMA_PTAU181_bl"
#> [1] "ConvertedToAlzheimers ~ AGE + GENDER + EDUCATION + PLASMA_NFL_bl"
#> [1] "ConvertedToAlzheimers ~ AGE + GENDER + EDUCATION + PLASMA_PTAU181_bl + PLASMA_NFL_bl"
#> [1] "CSF_ABETA_STATUS_bl ~ AGE + GENDER + EDUCATION"
#> [1] "CSF_ABETA_STATUS_bl ~ AGE + GENDER + EDUCATION + PLASMA_PTAU181_bl"
#> [1] "CSF_ABETA_STATUS_bl ~ AGE + GENDER + EDUCATION + PLASMA_NFL_bl"
#> [1] "CSF_ABETA_STATUS_bl ~ AGE + GENDER + EDUCATION + PLASMA_PTAU181_bl + PLASMA_NFL_bl"
my_table <- model %>% aba_demographics(strata = 'DX_bl')
print(my_table)
#> Stratified by DX_bl
#> Overall
#> n 2347 24
#> AGE (mean (SD)) 73.07 (7.43) 68.85 (8.30)
#> GENDER (mean (SD)) 0.53 (0.50) 0.38 (0.49)
#> EDUCATION (mean (SD)) 16.05 (2.75) 15.83 (2.16)
#> ConvertedToAlzheimers (mean (SD)) 0.20 (0.40) NaN (NA)
#> CSF_ABETA_STATUS_bl (mean (SD)) 0.62 (0.49) NaN (NA)
#> PLASMA_PTAU181_bl (mean (SD)) 2.71 (0.64) NaN (NA)
#> PLASMA_NFL_bl (mean (SD)) 3.54 (0.46) NaN (NA)
#> Stratified by DX_bl
#> AD CU
#> n 405 846
#> AGE (mean (SD)) 74.80 (7.92) 72.69 (6.34)
#> GENDER (mean (SD)) 0.57 (0.50) 0.44 (0.50)
#> EDUCATION (mean (SD)) 15.20 (2.91) 16.54 (2.53)
#> ConvertedToAlzheimers (mean (SD)) 0.00 (NA) 0.03 (0.18)
#> CSF_ABETA_STATUS_bl (mean (SD)) 0.88 (0.33) 0.39 (0.49)
#> PLASMA_PTAU181_bl (mean (SD)) 3.05 (0.41) 2.54 (0.67)
#> PLASMA_NFL_bl (mean (SD)) 3.77 (0.42) 3.45 (0.42)
#> Stratified by DX_bl
#> MCI p test
#> n 1072
#> AGE (mean (SD)) 72.80 (7.89) <0.001
#> GENDER (mean (SD)) 0.59 (0.49) <0.001
#> EDUCATION (mean (SD)) 15.99 (2.78) <0.001
#> ConvertedToAlzheimers (mean (SD)) 0.33 (0.47) NA
#> CSF_ABETA_STATUS_bl (mean (SD)) 0.63 (0.48) <0.001
#> PLASMA_PTAU181_bl (mean (SD)) 2.70 (0.64) <0.001
#> PLASMA_NFL_bl (mean (SD)) 3.52 (0.47) <0.001