Survival Analysis Fundamentals
This page covers the statistical theory behind the Survival Analysis tabs. See that page for usage instructions.
Time-to-Event Data and Censoring
Survival analysis is a set of methods for analyzing time until an event occurs. Despite the name "survival," the event need not be death — it can be machine failure, customer churn, time to recidivism, or any event of interest.
The defining feature of survival data is censoring. Subjects who did not experience the event during the observation period (e.g., patients still alive at the end of a clinical trial, or patients lost to follow-up) carry only incomplete information: "the event had not occurred by at least this time."
Simply excluding censored observations biases the analysis toward subjects who experienced the event sooner, underestimating survival times. Treating censored observations as "no event" overstates survival times since the true event time is unknown. Survival analysis methods are designed to handle censoring properly, provided that censoring is independent of event occurrence (independent censoring). Under independent censoring, the censoring carries no additional information about the event (it is non-informative), so the KM estimator and Cox model estimates remain unbiased. When censoring is related to the likelihood of the event — for example, when patients drop out due to worsening side effects — this assumption breaks down and the estimates become biased. MIDAS handles right censoring only (censoring due to end of observation or loss to follow-up). Left censoring (when the event had already occurred by the start of observation but its exact time is unknown) and interval censoring (when the event time can only be placed between two observation times) are not supported.
Why Ordinary Regression Fails
Without censoring, survival times could be analyzed as a response variable in ordinary regression. But censored data provides inequality information — "the true value is at least as large as the observed value" — and the usual residual () cannot be defined. Survival analysis incorporates this inequality into the likelihood function, correctly accounting for censoring.
Survival Function and Hazard Function
The distribution of survival time is characterized by two functions.
The survival function is the probability of not having experienced the event by time . It starts at and decreases monotonically over time.
The hazard function is the instantaneous rate of event occurrence at time , given survival up to that point:
The hazard is a rate (per unit time), not a probability, so it can exceed 1. The survival and hazard functions are related by ; knowing one determines the other.
Kaplan-Meier Estimator
The Kaplan-Meier estimator is a nonparametric estimator of the survival function. It makes no distributional assumptions, estimating directly from observed event times.
Let the distinct event times be , with subjects at risk and events at each time :
This cumulatively multiplies the "survival fraction" at each event time. Censoring is reflected through changes in the risk set: when a subject is censored, they leave the risk set but are not counted as an event.
When multiple events occur at the same time (ties), is the total number of events at that time and is the size of the risk set immediately before that time.
Under non-informative censoring, the KM estimator is a consistent estimator of . However, near the end of follow-up, censoring reduces the risk set, increasing variance and making the estimate unstable. The variance is estimated using Greenwood's formula, derived via the delta method:
Confidence intervals are constructed from this variance. Writing for the standard error of from Greenwood's formula, the standard error of is by the delta method. MIDAS uses the log transformation method, computing . The log transformation prevents the interval from falling outside .
RMST (Restricted Mean Survival Time)
RMST is the area under the survival function up to a restriction time .
It equals , the expected survival time when follow-up is restricted to . Unlike the hazard ratio, RMST does not require the proportional hazards assumption.
Since the KM estimator is a step function, the integral reduces to a sum of rectangles. Let be the event times at or before , with , , and :
Variance
Variation in the KM estimator at each event time propagates to RMST through the remaining area under the curve. Let (the area under the KM curve from to ):
The term is the same as in Greenwood's formula and captures the variation of the KM estimator at time . Each time point's contribution is weighted by , so earlier event times contribute more to the RMST variance.
RMST is asymptotically normal as . The confidence interval is therefore Wald-type: .
Group Differences
For the RMST difference between two groups, , the groups are independent, so the variance is the sum of each group's variance.
The confidence interval is Wald-type. For three or more groups, pairwise differences and confidence intervals are computed without multiplicity adjustment.
Cox Proportional Hazards Model
Model Formulation
The Cox (1972) proportional hazards model is a semiparametric model that estimates the effect of covariates on hazard:
is the baseline hazard (the hazard when all covariates are zero), and is the hazard ratio for a one-unit increase in covariate .
It is called "semiparametric" because is estimated parametrically, but no functional form is specified for . This removes the need to assume a distribution for the baseline hazard. After estimating , the cumulative baseline hazard can be estimated nonparametrically, which in turn allows computing the survival function for specific covariate values:
where . The estimator handles ties with the same Efron method used to estimate the coefficients. MIDAS outputs and at user-specified covariate values.
The covariates in this model are fixed values for each subject throughout the observation period. Handling covariates that change over time (time-varying covariates) requires extensions that MIDAS does not currently support.
Proportional Hazards Assumption
The core assumption is that covariate effects are constant over time. That is, the hazard ratio does not depend on .
When this assumption is violated (e.g., a treatment effect that fades over time), the estimated represents a weighted average of the time-varying effect, with weights that depend on the risk set composition and baseline hazard, making interpretation difficult. The weights of this average depend on the shape of the baseline hazard and cannot be determined in advance, so what the estimate is actually estimating is unknowable (Struthers & Kalbfleisch, 1986).
Schoenfeld Residuals
Schoenfeld residuals are used to diagnose potential violations of the proportional hazards assumption. They are defined at each event time for each covariate :
is the value of covariate for the subject who experienced the event. is the weighted mean of covariate over the risk set, defined as:
Here ranges over subjects in the risk set , is the covariate vector for subject , and is the linear predictor. The weight is subject-specific — subjects with higher hazard contribute more — and is the same for all covariates .
Under the Breslow approximation for ties, the sum of Schoenfeld residuals equals the score function (the gradient of the log partial likelihood with respect to ) (Schoenfeld, 1982). At the MLE the score function is zero, so the sum of residuals is also zero. MIDAS uses the Efron method for ties, so this equality does not hold exactly, but the sum is close to zero within convergence tolerance.
Scaled Schoenfeld residuals adjust the raw residuals by the variance-covariance matrix so that they can be interpreted asymptotically as estimates of :
where is the total number of events, and is the entry of (the estimated variance-covariance matrix). The factor adjusts the scale of the asymptotic covariance matrix. can be interpreted as an estimate of . Under proportional hazards, shows no systematic trend over time. Individual values have high variance, so the residuals are plotted against time and smoothed (e.g., with LOESS) to assess trends (Grambsch & Therneau, 1994).
MIDAS displays the following diagnostics (usage):
- Proportional Hazards Diagnostics: Displays the Pearson correlation (rho) between scaled Schoenfeld residuals and a KM-based time transform for each covariate
- Scaled Schoenfeld residual plots: Plots against time with a LOESS smooth
- log(-log(S(t))) plot: Plots Kaplan-Meier estimates as versus by group. Under proportional hazards, the curves should be approximately parallel
The rho uses the KM-based time transform as its time axis, while the residual plots use raw time on the horizontal axis. Since is a monotonically increasing transform of time, the direction of any trend agrees, but the axis scales differ.
Partial Likelihood
Cox model parameters are estimated using partial likelihood. For subject who experienced an event at time , consider the conditional probability that subject — among all subjects still at risk at that time — is the one who experiences the event:
Each factor corresponds to the conditional probability within the risk set at time . Substituting , the terms cancel between numerator and denominator, so estimating does not require knowing . The formula above assumes distinct event times. When multiple events occur at the same time (ties), the conditional probability is not uniquely defined, requiring an approximation. The Breslow method applies the same risk set to each tied event; the Efron method progressively reduces the risk set among tied events and is generally more accurate. MIDAS uses the Efron method.
Although the partial likelihood is not a full likelihood, it has been shown to yield estimators with the same asymptotic properties as maximum likelihood — consistency and asymptotic normality (Cox, 1975; Andersen & Gill, 1982).
Interpreting Hazard Ratios
Holding other covariates constant, is interpreted as the hazard ratio (HR):
- HR > 1: A one-unit increase in increases the hazard by
- HR < 1: The hazard decreases by
- HR = 1: has no effect on the hazard
The width of the confidence interval reflects estimation precision: a narrow interval indicates a more precise estimate, while a wide interval indicates limited information from the data. Hazard ratios convey the direction and magnitude of the effect together with the confidence interval, making them more informative than the p-value alone.
Model Fit Metrics
Cox regression reports discrimination and model comparison metrics.
Concordance Index
The concordance index (Harrell's C) measures how well the model predicts the ordering of survival times.
Among comparable pairs (where one subject experienced an event while the other was still at risk), concordance is the proportion where the risk score ordering agrees with the event ordering. A value of 0.5 indicates no discrimination (equivalent to random prediction); 1.0 indicates perfect discrimination.
The standard error is estimated via the influence function (infinitesimal jackknife). For each observation , the influence is , where is the number of concordant pairs involving observation , is the number of comparable pairs, is the concordance, and is the total number of comparable pairs. Then .
AIC
where is the partial log-likelihood and is the number of covariates. Lower values indicate a better balance between fit and parsimony. Use AIC to compare models with different covariate sets.
See also
- Survival Analysis - Usage instructions and interpreting results
- Tutorial: Kaplan-Meier Analysis - A practical example with sample data
References
- Cox, D. R. (1972). Regression models and life-tables. Journal of the Royal Statistical Society: Series B, 34(2), 187-220. https://www.jstor.org/stable/2985181
- Kaplan, E. L., & Meier, P. (1958). Nonparametric estimation from incomplete observations. Journal of the American Statistical Association, 53(282), 457-481. https://www.jstor.org/stable/2281868
- Cox, D. R. (1975). Partial likelihood. Biometrika, 62(2), 269-276. https://www.jstor.org/stable/2335362
- Andersen, P. K., & Gill, R. D. (1982). Cox's regression model for counting processes: A large sample study. The Annals of Statistics, 10(4), 1100-1120. https://www.jstor.org/stable/2240714
- Struthers, C. A., & Kalbfleisch, J. D. (1986). Misspecified proportional hazard models. Biometrika, 73(2), 363-369. https://www.jstor.org/stable/2336212
- Schoenfeld, D. (1982). Partial residuals for the proportional hazards regression model. Biometrika, 69(1), 239-241. https://www.jstor.org/stable/2335876
- Grambsch, P. M., & Therneau, T. M. (1994). Proportional hazards tests and diagnostics based on weighted residuals. Biometrika, 81(3), 515-526. https://www.jstor.org/stable/2337123
Also available as a Markdown file.