Skip to contents

Usage

generalizedroc(
  data,
  outcome,
  predictor,
  assume_equal_variance = FALSE,
  transformation = "none",
  distribution_model = "normal",
  calculate_auc = TRUE,
  confidence_intervals = TRUE,
  ci_method = "bootstrap",
  bootstrap_samples = 1000,
  confidence_level = 0.95,
  show_diagnostics = TRUE,
  variance_test = "levene",
  optimal_threshold = TRUE,
  plot_roc = TRUE,
  plot_distributions = TRUE,
  plot_diagnostic = FALSE,
  random_seed = 42,
  use_tram = FALSE,
  covariates = NULL,
  tram_model = "Colr",
  covariate_values = "0, 0.5, 1",
  plot_covariate_roc = TRUE,
  plot_auc_vs_covariate = TRUE,
  n_covariate_points = 50,
  tram_constraints = "none",
  censoring_aware = FALSE
)

Arguments

data

the data as a data frame

outcome

a string naming the outcome variable (binary or ordinal)

predictor

a string naming the continuous predictor variable

assume_equal_variance

if TRUE, assumes equal variance across groups (standard ROC); if FALSE, allows unequal variances (generalized ROC)

transformation

transformation applied to predictor before analysis

distribution_model

assumed distribution for each group

calculate_auc

calculate area under the generalized ROC curve

confidence_intervals

calculate confidence intervals for AUC and other parameters

ci_method

method for confidence interval calculation

bootstrap_samples

number of bootstrap samples for CI calculation

confidence_level

confidence level for intervals (default: 0.95 for 95\

show_diagnosticsshow diagnostic tests for normality and variance equality

variance_testtest for equality of variances across groups

optimal_thresholdfind optimal threshold using Youden's index

plot_rocplot the generalized ROC curve

plot_distributionsplot predictor distributions for each outcome group

plot_diagnosticplot Q-Q plots for normality assessment

random_seedrandom seed for reproducible bootstrap sampling

use_tramUse tram package for covariate-adjusted transformation models

covariatesCovariates to include in transformation model

tram_modelType of transformation model from tram package

covariate_valuesComma-separated covariate values for ROC evaluation

plot_covariate_rocPlot ROC curves as function of covariate values

plot_auc_vs_covariatePlot how AUC changes across covariate values

n_covariate_pointsNumber of points to evaluate across covariate range

tram_constraintsConstraints on transformation function

censoring_awareUse censoring-aware transformation models

A results object containing:

results$instructionsTexta html
results$aucTablea table
results$parametersTablea table
results$diagnosticsTablea table
results$thresholdTablea table
results$rocPlotan image
results$distributionPlotan image
results$qqPlotan image
results$interpretationTexta html
Tables can be converted to data frames with asDF or as.data.frame. For example:results$aucTable$asDFas.data.frame(results$aucTable) Generalized ROC (gROC) Analysis extends traditional binary ROC to handle continuous or ordinal outcomes, particularly when the outcome distributions have unequal variances across groups. This method is particularly useful for continuous biomarkers (PD-L1 CPS, Ki67 percentage), quantitative imaging features, and ordinal scales where traditional ROC assumptions may be violated.The generalized approach models the full distribution rather than imposing binary cutoffs, providing more flexible and robust performance assessment. # Example with continuous Ki67 percentage data <- data.frame( outcome = factor(sample(c("Low", "High"), 100, replace=TRUE)), ki67_percent = c(rnorm(50, 10, 5), rnorm(50, 40, 15)) )generalizedroc( data = data, outcome = 'outcome', predictor = 'ki67_percent', assume_equal_variance = FALSE, transformation = 'none' )