Skip to contents

Implements robust Cox proportional hazards regression models that are resistant to outliers and model misspecification. Provides multiple robust estimation methods including Huber M-estimation, bounded influence functions, and weighted partial likelihood approaches for reliable survival analysis in the presence of data anomalies.

Usage

coxrobust(
  data,
  elapsedtime,
  outcome,
  covariates,
  outcomeLevel = "1",
  robust_method = "huber",
  tuning_constant = 1.345,
  efficiency_target = 0.95,
  max_iterations = 100,
  convergence_tolerance = 1e-06,
  outlier_detection = TRUE,
  outlier_threshold = 3,
  stratify_variable,
  weights_variable,
  bootstrap_ci = FALSE,
  bootstrap_samples = 500,
  confidence_level = 0.95,
  show_model_summary = TRUE,
  show_coefficients = TRUE,
  show_outliers = TRUE,
  show_influence = TRUE,
  show_comparison = TRUE,
  show_residual_plots = TRUE,
  show_influence_plots = TRUE,
  show_weight_plots = TRUE,
  show_survival_plots = TRUE,
  showSummaries = FALSE,
  showExplanations = FALSE
)

Arguments

data

the data as a data frame

elapsedtime

Survival time or follow-up duration variable

outcome

Event indicator variable (0/1, FALSE/TRUE, or factor)

covariates

Predictor variables for the Cox model

outcomeLevel

Level of outcome variable indicating event occurrence

robust_method

Robust estimation method to use

tuning_constant

Tuning constant for robust estimation (method-specific)

efficiency_target

Target efficiency relative to standard Cox model

max_iterations

Maximum number of iterations for robust estimation

convergence_tolerance

Convergence tolerance for parameter estimation

outlier_detection

Perform automatic outlier detection and flagging

outlier_threshold

Threshold for outlier detection (in standard deviations)

stratify_variable

Variable for stratified analysis

weights_variable

Optional observation weights

bootstrap_ci

Compute bootstrap confidence intervals

bootstrap_samples

Number of bootstrap samples for CI estimation

confidence_level

Confidence level for intervals

show_model_summary

Display comprehensive model summary

show_coefficients

Display coefficient estimates table

show_outliers

Display outlier detection results

show_influence

Display influence diagnostics

show_comparison

Compare robust vs standard Cox models

show_residual_plots

Display residual diagnostic plots

show_influence_plots

Display influence diagnostic plots

show_weight_plots

Display robust weight distributions

show_survival_plots

Display survival curves

showSummaries

Generate natural language summaries

showExplanations

Show detailed methodology explanations

Value

A results object containing:

results$modelSummarya table
results$coefficientsa table
results$outlierAnalysisa table
results$influenceMeasuresa table
results$modelComparisona table
results$convergenceInfoa table
results$residualPlotsan image
results$influencePlotsan image
results$weightPlotsan image
results$survivalPlotsan image
results$outlierPlotsan image
results$comparisonPlotsan image
results$summaryTablea html
results$methodExplanationa html

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

results$modelSummary$asDF

as.data.frame(results$modelSummary)

Examples

# Example: Robust Cox regression
library(survival)
library(coxrobust)

coxrobust(
    data = lung_data,
    elapsedtime = "time",
    outcome = "status",
    outcomeLevel = "2",
    covariates = c("age", "sex", "ph.ecog"),
    robust_method = "huber",
    tuning_constant = 1.345
)