Skip to contents

Build and validate clinical prediction models with integrated calibration and discrimination metrics. Supports logistic regression with stepwise/LASSO selection, ROC analysis, calibration plots, and bootstrap validation.

Usage

predmodel(
  data,
  outcome,
  predictors,
  modelSelection = "none",
  validationMethod = "bootstrap",
  nBootstrap = 200,
  nFolds = 10,
  showCalibration = TRUE,
  showDiscrimination = TRUE,
  showRiskGroups = TRUE,
  riskCutoffs = "0.33, 0.67",
  ciLevel = 0.95
)

Arguments

data

The data as a data frame.

outcome

Binary outcome variable (disease/event vs. no disease/no event).

predictors

Continuous or categorical predictor variables for the model.

modelSelection

Method for variable selection.

validationMethod

Internal validation method to assess model performance.

nBootstrap

Number of bootstrap samples for optimism correction.

nFolds

Number of folds for cross-validation.

showCalibration

Display calibration plot and Hosmer-Lemeshow test.

showDiscrimination

Display ROC curve, AUC, and Brier score.

showRiskGroups

Stratify patients into risk groups (low/medium/high).

riskCutoffs

Comma-separated risk probability cutoffs (e.g., "0.25, 0.75").

ciLevel

Confidence level for intervals (0.80-0.99).

Value

A results object containing:

results$modelSummarya html
results$coefficientsa table
results$discriminationMetricsa table
results$calibrationMetricsa table
results$riskStratificationa table
results$validationMetricsa table
results$rocPlotan image
results$calibrationPlotan image
results$interpretationa html

Tables can be converted to data frames with asDF or as.data.frame. For example:

results$coefficients$asDF

as.data.frame(results$coefficients)

Examples

# Example usage:
# data <- your_data
# ClinicoPath::predmodel(
#   data = data,
#   outcome = "disease",
#   predictors = vars(age, biomarker, stage),
#   validation = "bootstrap",
#   calibration = TRUE
# )