Skip to contents

Performs comprehensive univariate and stratified survival analysis comparing survival between groups. This analysis calculates person-time follow-up for each group and uses this to derive accurate survival estimates and incidence rates that account for varying follow-up durations across groups. The Cox proportional hazards model incorporates person-time by modeling the hazard function, which represents the instantaneous event rate per unit of person-time.

Key Features:

  • Kaplan-Meier survival curves with multiple plot types

  • Cox proportional hazards regression (univariate and stratified)

  • Median survival time with confidence intervals

  • Restricted Mean Survival Time (RMST) analysis

  • Person-time analysis with incidence rates

  • Competing risks and cause-specific survival

  • Landmark analysis for conditional survival

  • Proportional hazards assumption testing

  • Model residual diagnostics

  • Pairwise group comparisons with multiple testing correction

Statistical Methods:

  • Kaplan-Meier estimator for survival probabilities

  • Log-rank test for group comparisons

  • Cox proportional hazards model for risk assessment

  • Competing risks analysis using cumulative incidence functions

  • RMST for robust survival comparisons

Visualization Options:

  • Standard survival curves

  • Cumulative events and hazard plots

  • KMunicate-style plots for publication

  • Log-log plots for proportional hazards assessment

  • Residual diagnostic plots

Value

A comprehensive results object containing survival analysis outputs

Details

Analysis Types:

  • Overall Survival: Time from study entry to death from any cause

  • Cause-Specific Survival: Time to death from specific cause (censoring other deaths)

  • Competing Risks: Accounts for multiple types of events that prevent observation of the primary outcome

Person-Time Analysis: Calculates incidence rates accounting for varying follow-up times. Particularly useful for:

  • Studies with differential loss to follow-up

  • Comparison of event rates across populations

  • Assessment of time-varying risk

Restricted Mean Survival Time (RMST): Alternative to median survival when survival curves don't reach 50% or for comparing survival over a specific time horizon. Represents the area under the survival curve up to a specified time point.

Model Diagnostics:

  • Proportional hazards assumption testing using Schoenfeld residuals

  • Martingale and deviance residuals for outlier detection

  • Log-log plots for visual assessment of proportional hazards

References

Klein JP, Moeschberger ML (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer.

Therneau TM, Grambsch PM (2000). Modeling Survival Data: Extending the Cox Model. Springer.

Royston P, Parmar MK (2013). Restricted mean survival time: an alternative to the hazard ratio for the design and analysis of randomized trials with a time-to-event outcome. BMC Medical Research Methodology 13:152.

Super classes

jmvcore::Analysis -> ClinicoPath::survivalBase -> survivalClass

Examples

# \donttest{
# Basic survival analysis
data("histopathologySurvival", package = "ClinicoPathJamoviModule")
#> Error in find.package(package, lib.loc, verbose = verbose): there is no package called ‘ClinicoPathJamoviModule’

# Standard survival analysis with median and survival probabilities
survival_result <- survival(
  data = histopathologySurvival,
  elapsedtime = "OverallSurvival_indays",
  outcome = "Outcome",
  outcomeLevel = "Dead",
  explanatory = "Grade",
  timetypeoutput = "months",
  cutp = "12, 36, 60",
  sc = TRUE,
  pw = TRUE
)
#> Error: object 'histopathologySurvival' not found

# Survival analysis with person-time metrics
survival_with_pt <- survival(
  data = histopathologySurvival,
  elapsedtime = "OverallSurvival_indays", 
  outcome = "Outcome",
  outcomeLevel = "Dead",
  explanatory = "Stage",
  person_time = TRUE,
  time_intervals = "365, 1095, 1825",
  rate_multiplier = 1000
)
#> Error: object 'histopathologySurvival' not found

# RMST analysis for non-proportional hazards
rmst_analysis <- survival(
  data = histopathologySurvival,
  elapsedtime = "OverallSurvival_indays",
  outcome = "Outcome", 
  outcomeLevel = "Dead",
  explanatory = "Treatment",
  rmst_analysis = TRUE,
  rmst_tau = 1095  # 3 years
)
#> Error: object 'histopathologySurvival' not found

# Competing risks analysis
competing_risks <- survival(
  data = cancer_data,
  elapsedtime = "survival_days",
  outcome = "death_cause",
  multievent = TRUE,
  dod = "Cancer",
  dooc = "Other",
  awd = "Alive_Disease",
  awod = "Alive_Free",
  analysistype = "compete",
  explanatory = "risk_group"
)
#> Error in survival(data = cancer_data, elapsedtime = "survival_days", outcome = "death_cause",     multievent = TRUE, dod = "Cancer", dooc = "Other", awd = "Alive_Disease",     awod = "Alive_Free", analysistype = "compete", explanatory = "risk_group"): argument "strata_variable" is missing, with no default

# Landmark analysis for conditional survival
landmark_survival <- survival(
  data = histopathologySurvival,
  elapsedtime = "OverallSurvival_indays",
  outcome = "Outcome",
  outcomeLevel = "Dead", 
  explanatory = "Grade",
  uselandmark = TRUE,
  landmark = 365  # 1-year conditional survival
)
#> Error: object 'histopathologySurvival' not found

# Date-based survival calculation
date_survival <- survival(
  data = clinical_data,
  tint = TRUE,
  dxdate = "diagnosis_date",
  fudate = "last_contact_date",
  timetypedata = "ymd",
  timetypeoutput = "months",
  outcome = "vital_status",
  outcomeLevel = "Dead",
  explanatory = "treatment_arm"
)
#> Error: object 'clinical_data' not found
# }