Skip to contents

This function calculates power for a diagnostic test based on fitted results of an aba model. The sensitivity/specificity and prevalance will be extracted from the fitted model and 'n', 'power', or 'delta' can be calculated against a null hypothesis performance. This function can be useful if you have pilot data and want to plan a larger experiment based on this information rather than making less data-driven assumptions.

Usage

aba_diagnosticpower(model, delta = NULL, n = NULL, metric = c("sens", "spec"))

Arguments

model

fitted aba model. The model you want to run power analysis on.

delta

value between 0 and 0.5. The half-size of the confidence interval that you want to (or will) acheive on the estimated sensitivity/specificity. Either delta or n should be specified.

n

integer. The number of positive cases (for sensitivity) or negative cases (for specificity) that you want to (or need to) include. Either delta or n should be specified.

metric

string: sens or spec. The metric of interest - either sensitivity or specificity

Value

a data frame with results from the power.diagnostic.test function for each fit in the aba model.

Examples

# We fit a diagnostic model on pilot data.
data <- adnimerge %>% dplyr::filter(VISCODE == 'bl', DX_bl == 'MCI')
model <- data %>% aba_model() %>%
  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(
    stat_glm(std.beta = TRUE)
  ) %>%
  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"

# What will the delta on sensitivity be with 100 subjects
res_delta <- model %>% aba_diagnosticpower(n = 100)

# How many subjects do we need to acheive a delta of 0.1 on sensitivity
res_n <- model %>% aba_diagnosticpower(delta = 0.1)