survival_analysis
Perform survival analysis: compute Kaplan-Meier curves, median survival, and log-rank tests, or fit Cox proportional hazards models with hazard ratios and assumption checks.
Instructions
Survival / time-to-event analysis. type='km' gives Kaplan-Meier estimates with median survival, a survival curve, and a log-rank test when group is supplied; times_of_interest adds survival probabilities at chosen follow-up times. type='cox' fits a Cox proportional hazards model with hazard ratios, concordance, and the Schoenfeld test of the proportional-hazards assumption. event must be coded 1 = event occurred, 0 = censored.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Dataset name in the session. | |
| time | Yes | Follow-up time column. | |
| type | No | km, cox, or auto (cox when covariates are given). | auto |
| event | Yes | Event indicator column: 1 = event occurred, 0 = censored. | |
| group | No | Grouping column to compare survival across. | |
| plots | No | Include the survival curve. | |
| time2 | No | End time, for interval-censored or time-varying data. | |
| digits | No | Decimal places. | |
| save_as | No | Name for the fitted model in the session. | |
| conf_level | No | Confidence level. | |
| covariates | No | Predictors for a Cox model. | |
| times_of_interest | No | Report survival probability at these times, e.g. [365, 730]. |