Statistics Glossary → Cox Regression (Proportional Hazards Model)
Cox Regression (Proportional Hazards Model)analysis
A survival model that shows how several factors together affect the time until an event (death, relapse, failure, leaving a job), giving a hazard ratio (HR) for each factor.
Concept
In survival data the outcome combines two questions: did the event happen, and when? For some subjects the event has not yet occurred when the study ends; these are censored observations and must be kept in the model rather than discarded. This is why survival models are used instead of ordinary regression.
The Cox model writes the risk of the event at any moment (the hazard) as a baseline hazard multiplied by the effect of the covariates: h(t) = h₀(t) · exp(β₁x₁ + β₂x₂ + …). The shape of the baseline hazard is never specified; the model estimates only the relative effects of the factors. The exponential of each coefficient, exp(β), is the hazard ratio: HR = 2 says that a one-unit increase in that factor doubles the instantaneous risk; HR = 0.5 halves it.
The key assumption is proportional hazards: the ratio of two subjects' risks is constant over time. It is checked with Schoenfeld residuals; for factors that violate it, stratification or time-dependent effects are used.
When to use it
- When the interest is in time to an event and some observations are censored (clinical follow-up, machine lifetime, customer churn).
- When several risk factors are to be assessed at once, seeing the effect of each independently of the others.
- If comparing survival curves between groups is enough, use Kaplan-Meier and the log-rank test; if several event types preclude one another, use competing risks analysis.
An everyday example
A company follows how long its subscribers stay before cancelling. Some subscribers are still subscribed, so when they will cancel is unknown (censored). Cox regression puts age, monthly fee and the number of complaints to customer service into the model together and might find a hazard ratio of 1.40 for complaints: holding the other factors fixed, each additional complaint raises the risk of cancelling at any given moment by about 40%.
Parameters in MerQur
Time, Event and Predictors
Concept: A survival model has three inputs: the time until the event, an indicator of whether the event occurred (1 = event, 0 = censored) and the covariates thought to affect the risk. A censored subject is not someone who 'had no event'; it only says the event was not seen during the follow-up time.
Everyday example: Each subscriber's row holds how many months they stayed (time), whether they cancelled (event) and their age, monthly fee and number of complaints (covariates). Someone who is still subscribed is coded 0; they are not counted as cancelling, but the fact that they have not cancelled so far still enters the model.
What it does: Time (≥ 0), the event indicator (0/1) and the covariates. Text columns are coded categorically.
Effect on the result: The whole model changes.
On the validation data: In all cases n, the number of events, coefficient, SE, z, p, HR and intervals are given. Coefficients are shown on screen with 4 decimals and p values with 6; for small coefficients (VA Duration 0.0032) the number of significant digits is small.
Event code (values)
Concept: When the status column uses codes other than 0/1 or has more than two values, this states which value counts as the event; all remaining values are treated as censored.
Everyday example: If the company records status as 1 = still subscribed and 2 = cancelled, the event code is 2. The model then reads subscribers coded 1 as censored and those coded 2 as having cancelled.
What it does: In a multi-valued status column, specifies the value(s) counted as events; the others are censored.
Effect on the result: Rebuilds the event indicator.
On the validation data: For lung status 1/2, code "2": sex -0.5526 (SE 0.1677), ph.ecog 0.4637. When left empty, MerQur gives the error "Event column must contain only 0 and 1"; for a 1/2-coded column the event code must be entered explicitly.
Confidence Level (%90 / %95 / %99 / Other, custom value)
Concept: Sets how much confidence the interval for each hazard ratio carries. Because the interval is built symmetrically on the log scale of the coefficient and then exponentiated, it is not symmetric around the HR.
Everyday example: Suppose the HR for complaints is 1.40 with a 95% confidence interval of [1.20, 1.63]: each extra complaint can be said to raise the risk of cancelling by at least 20% and at most 63%. Asking for 99% confidence widens the interval and pulls the lower limit towards 1.
What it does: The Wald interval exp(b ± z·SE) for the HR. The significance mark is also given according to the selected α.
Effect on the result: Only the interval limits change (coefficient, SE, p do not change).
On the validation data: VA Therapy_test HR interval: 95% (1.092, 2.886), 90% (1.181, 2.669), 99% (0.937, 3.363), 80% (1.292, 2.439), 99.9% (0.785, 4.015).
Proportional hazards test (Schoenfeld) and PH test time transform (Kaplan-Meier / Rank / Time (identity) / log t)
Concept: The proportional hazards assumption says that the factor by which a variable raises or lowers the risk stays constant over follow-up. If the Schoenfeld residuals show a clear trend against time, the assumption is violated; the time transformation sets the time scale (raw time, log time, rank) on which this trend is sought.
Everyday example: If complaints have a very strong effect in the first months of a subscription but a weak one after a year, a single HR of 1.40 does not summarise the whole period well. The test comes out significant for the complaints variable and signals that its effect changes over time.
What it does: The Grambsch-Therneau score test (per term and global) and the scaled Schoenfeld residuals. 1-KM(t-), rank, t or log t is used as g(t). It is not computed with the exact ties method (a warning is written).
Effect on the result: Only the PH test section changes; when off, no other output changes.
On the validation data: veteran (trt, prior, karno) global χ²: km 18.073, rank 18.806, time 11.439, log t 14.961; karno km 12.138. In the ovarian data age 0.698, ecog.ps 2.371, global 3.633.
Strata variable (STRATA)
Concept: Stratification gives each stratum its own baseline hazard while treating the covariate effects as common across strata. It is a way to control for a variable that violates proportionality; the price is that no HR is estimated for the stratifying variable.
Everyday example: If individual and business subscribers leave in very different patterns over time, subscription type is used as a stratum. The model uses a separate baseline risk curve for each type, but reports the effect of complaints as one HR shared by both.
What it does: A separate baseline hazard for each stratum, common β.
Effect on the result: Coefficients and baseline survival change.
On the validation data: actg320 cd4_q stratum (Breslow): tx -0.6678 (SE 0.2155; unstratified -0.7283).
Ties method (Efron / Breslow / Exact)
Concept: When several subjects have the event at the same recorded time (tied times), the order in which they had it is unknown, and one must choose how the partial likelihood handles this. Breslow is the crudest approximation, Efron is more accurate and the exact method accounts for ties fully; with few ties the three give nearly the same result.
Everyday example: When time is recorded in months, dozens of subscribers cancel within the same month and the order in which they left is unknown. With so many ties, Efron or the exact method estimates the coefficients with less bias than Breslow.
What it does: The partial likelihood approximation for those who experience the event at the same time. MerQur's "exact" option is the discrete-time (conditional logistic) exact likelihood.
Effect on the result: Coefficients, SE and likelihood change.
On the validation data: VA Cell_squamous: Efron -1.1996, Breslow -1.1913, exact -1.2060; LL -472.25 / -473.07 / -447.69 (the exact likelihood is on a different scale).
Categorical coding (Indicator first / Indicator last / Deviation)
Concept: A categorical covariate enters the model as indicator (dummy) variables. With indicator coding, each level's HR is read against the chosen reference level; with deviation coding, levels are compared with the average of all levels.
Everyday example: Let the plan type be 'basic', 'standard' and 'premium'. With 'basic' as the reference, an HR of 0.60 for premium means premium subscribers have about 40% lower risk of cancelling at any moment than basic ones. Changing the reference changes the numbers, but the model itself is the same.
What it does: Indicator coding (reference first or last level) or deviation coding (last level -1) for text covariates; levels are alphabetical. Applied only to non-numeric columns.
Effect on the result: The reference and interpretation of the coefficients change.
On the validation data: VA Cell (model with the Prior*Therapy interaction, Efron ties method): first (baseline level adeno) large -0.7906 (-0.7836 with Breslow); last (baseline level squamous) adeno 1.1996, large 0.4089, small 0.8950; deviation adeno 0.5737, large -0.2169, small 0.2691.
Interactions (a*b, a:b)
Concept: An interaction tests whether the effect of one factor on the risk depends on the level of another. In a Cox model, the interaction term shows by what factor one variable's HR is multiplied for each unit increase in the other.
Everyday example: The effect of complaints on cancelling may be stronger for subscribers paying a high fee: a customer on an expensive plan gives up more easily after a problem. The fee*complaints term tests whether this difference can be explained by chance.
What it does: a*b adds the main effects and the product, a:b adds only the product.
Effect on the result: The model terms change.
On the validation data: VA Prior*Therapy -0.87579 (SE 0.42976); Prior:Therapy product only -0.1849; whas500 gender*age 2.32852 / 0.07840 / -0.03043.
Variable selection (Enter / Forward LR / Backward LR / AIC both directions)
Concept: Decides which covariates stay in the model: Enter keeps them all, while stepwise methods add or remove variables according to a statistical criterion. Stepwise selection is exploratory; the p values and confidence intervals of the chosen model look more optimistic than they are.
Everyday example: The company has 15 candidate variables (region, device type, payment method…) and does not know which matter. Backward elimination drops the unimportant-looking ones one by one; but whether the resulting model holds in another sample of subscribers must be checked with new data.
What it does: Entry score p < 0.05, removal LR p > 0.10; the AIC option is two-directional. When an interaction is in the model, its components are not removed.
Effect on the result: The terms remaining in the model change.
On the validation data: VA backward (LR): Duration and Age are removed, {Kps, Cell, Prior, Therapy, Prior*Therapy} remain; backward elimination respects the hierarchy, so main effects that form an interaction in the model are not removed. VA forward (LR): {Kps, Cell}.
Cluster (robust SE)
Concept: When observations are not independent within clusters, ordinary standard errors come out too small. The robust (sandwich) variance accounts for within-cluster dependence; the coefficients do not change, only the standard errors, p values and confidence intervals are corrected.
Everyday example: Several subscriptions in the same household (e.g. family lines) are often cancelled together. Giving the household ID as the cluster stops the model from counting these subscriptions as independent pieces of information and overstating its precision.
What it does: Lin-Wei sandwich variance; the SE, p, CI and term tests are robust, and the naive SE and the robust Wald are given separately.
Effect on the result: SE, p and interval change.
On the validation data: Blind (ID, 197 clusters): Treat_Laser SE 0.1850 (naive 0.2177); lung (inst, 18 clusters) robust Wald 33.861. If a robust SE is requested with the exact ties method, an error is given.
Extra outputs: Residual diagnostics and Save residuals to dataset
Concept: Residuals show how well the model fits individual observations. The martingale residual is the difference between the observed event and the amount of event the model expected for that subject; the deviance residual is a symmetric version suited to spotting outliers; Cox-Snell residuals check overall fit, and dfbeta shows how much one observation changes the coefficients.
Everyday example: A subscriber with a large negative martingale residual is one whom the model expected to have cancelled long ago but who stayed. Dfbeta shows how much a single subscriber moves the complaints coefficient; if it is very large, that record is worth checking.
What it does: Martingale, deviance, Cox-Snell, Xb and dfbeta residuals; a summary (min, Q1, median, Q3, max) and the 5 most influential rows. "Save" adds them to the dataset as columns.
Effect on the result: Adds output; saving does not change the text.
On the validation data: VA martingale min -5.731, median 0.288, max 0.991. There is no dfbeta with the exact ties method.
→ Cox model residuals (martingale, deviance, Cox-Snell, dfbeta)
Example on real data
Data: VA lung cancer, Kalbfleisch and Prentice 1980; SAS PHREG
Variables: time Time (days), event Status, predictors Kps, Duration, Age, Cell, Prior, Therapy
- Question: In patients with lung cancer (n = 137, 128 deaths), how do treatment, cell type, Karnofsky performance score (Kps), time since diagnosis, age and prior therapy jointly affect the risk of death?
- Model test: The results in this interpretation come from the model without interactions (main effects, Efron ties method). Likelihood ratio χ²(8) = 62.10, p < .001; the covariates jointly explain the risk significantly. C-index = 0.736 (good discrimination).
- Result: The risk decreases as Kps increases: HR = 0.968, 95% CI [0.957, 0.978], p < .001 (each point lowers the risk by about 3.2%). Compared with the adeno cell type, the risk is lower for the large (HR = 0.452, p = .009) and squamous (HR = 0.302, p < .001) cell types; the joint Wald χ²(3) for Cell = 18.14, p < .001.
- Non-significant covariates: Treatment (HR = 1.34, p = .156), time since diagnosis, age and prior therapy are not significant.
- Assumption: Proportional hazards test GLOBAL χ²(8) = 34.55, p < .001; the PH assumption appears to be violated for Cell (p = .0016) and Kps (p = .0003). Stratification or a time-varying effect should be considered for these variables.
- APA: In Cox regression, the Karnofsky score, HR = 0.97, 95% CI [0.96, 0.98], p < .001, and cell type, Wald χ²(3) = 18.14, p < .001, significantly predicted survival; LR χ²(8, N = 137) = 62.10, p < .001.
Related concepts
Hazard ratio (HR)Censoring (survival analysis)Proportional hazards assumptionTies method (Efron, Breslow, exact)Confidence level and confidence intervalStepwise variable selectionInteraction effectCox model residuals (martingale, deviance, Cox-Snell, dfbeta)Cluster-robust (clustered) standard errors
The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.