Signature
r = exp(beta); dH = d / (n0 + n1 * r); H = H_prev + dH; S_0 = exp(-H); S_1 = S_0^r
| Inputs | Definition | Unit |
|---|---|---|
beta | Estimated Cox coefficient of the binary covariate, held fixed | log hazard ratio, no unit |
d | Number of events at this time | events |
n0 | Number with x = 0 at risk just before this time | people |
n1 | Number with x = 1 at risk just before this time | people |
H_prev | Running total of the increments at earlier event times, 0 before the first | events per person |
r | Exponential of beta, the risk score of a person with x = 1 | ratio, no unit |
|---|---|---|
dH | Events divided by the summed risk scores of those at risk | events per person |
H | Running total including this time's increment | events per person |
S_0 | Estimated survival for a person with x = 0 just after this time | probability |
S_1 | Estimated survival for a person with x = 1 just after this time | probability |
Function
Cox proportional hazards model function for hazards, partial likelihood and baseline curves
Maps right-censored survival records with covariates to the coefficients of the Cox model, their standard errors and the estimated baseline curve. HE-FM-CPH-001 gives the hazard and survival of one covariate profile from a baseline and a linear predictor, HE-FM-CPH-002 the partial likelihood over the risk sets, HE-FM-CPH-003 one step of the Breslow baseline cumulative hazard, HE-FM-CPH-004 the Breslow and Efron terms for two tied deaths, and HE-FM-CPH-005 a hazard ratio that changes with log time. HE-CF-CPH-001 maximises the partial likelihood by Newton-Raphson. HE-FM-HR-002 turns a coefficient into a hazard ratio, HE-FM-HR-006 gives its confidence interval, HE-FN-CUMH-001 links a cumulative hazard to survival and HE-FM-HR-003 is the power rule for a survival curve, and none of these is restated here as a formula of its own. Notation follows the Cox Proportional Hazards article.
Try this function
Implementations
Excel
Excel Breslow baseline step with one row per Cox event time
With LogHazardRatio, EventsNow, ComparatorAtRisk, TreatedAtRisk and HazardBefore on each row, where HazardBefore is 0 on the first row and the CumHazard of the row above after that, the formulas go in RiskRatio, HazardIncrement, CumHazard, SurvComparator and SurvTreated. For the article's three times, CumHazard on the three rows is also named CumHazardFirst, CumHazardSecond and CumHazardThird.
=EXP(LogHazardRatio); =EventsNow/(ComparatorAtRisk+TreatedAtRisk*RiskRatio); =HazardBefore+HazardIncrement; =EXP(-CumHazard); =SurvComparator^RiskRatio
Assumptions
Coefficient fixed at its Cox estimate in the baseline step
The risk scores use the fitted beta, so the curve depends on the fit and on proportional hazards through S_1 = S_0^r. Several tied events at one time enter through d, which is the Breslow rule; HE-FM-CPH-004 gives the Efron increment. The binary form n0 + n1 r applies to one 0 and 1 covariate; with other covariates each person keeps an individual score.
Cox baseline curve read only within observed follow-up
The estimate exists at observed event times only. TSD 14 notes that a Cox model bases inferences only upon observed data, and that such methods are only likely to be reasonable when data are almost entirely complete. Lifetime modelling needs a parametric or flexible curve, as under the Parametric Survival Model concept.
Worked examples
Article's baseline step at 2 months
First death in the article's illustrative trial, with all four patients at risk. The figures round to the article's table, 0.360, 0.698 and 0.869.
beta = -0.9406; d = 1; n0 = 2; n1 = 2; H_prev = 0; r = 0.3904; dH = 0.3596; H = 0.3596; S_0 = 0.6979; S_1 = 0.869
Article's baseline step at 3 months
Second death, with one comparator and two treated patients at risk. The figures round to the article's 0.562, 0.921, 0.398 and 0.698.
beta = -0.9406; d = 1; n0 = 1; n1 = 2; H_prev = 0.3596; r = 0.3904; dH = 0.5615; H = 0.9211; S_0 = 0.3981; S_1 = 0.6979
Article's baseline step at 5 months
Third death, with one patient at risk in each arm. The figures round to the article's 0.719, 1.640, 0.194 and 0.527, and the curves then stay flat until the censoring at 7 months.
beta = -0.9406; d = 1; n0 = 1; n1 = 1; H_prev = 0.9211; r = 0.3904; dH = 0.7192; H = 1.6403; S_0 = 0.1939; S_1 = 0.5271
Two tied deaths at time 6 in Therneau's test data 1
The Breslow column of Therneau's Table 1, with increments of 1/(r + 3) for each of the two deaths, taken together through d = 2. The total of 0.3333 agrees with basehaz from coxph with Breslow ties.
beta = 1.475285; d = 2; n0 = 3; n1 = 1; H_prev = 0.062; r = 4.3723; dH = 0.2713; H = 0.3333; S_0 = 0.7166; S_1 = 0.2329
Common errors
Leaving the risk scores out of the Breslow increment
Plain increments of 1/4, 1/3 and 1/2 give a cumulative hazard of 1.0833 at 5 months and comparator survival of 0.3385, against 1.6403 and 0.1939 with the risk scores in the article's example. They are correct only at beta = 0.
Using a Cox baseline curve and hazard ratio beyond follow-up
The curve in the article's example stays flat after 5 months until the censoring at 7 and has no value beyond that. Holding it flat or extending it gives no estimate of lifetime survival. TSD 14 section 2.9 also states that it is theoretically incorrect to apply a hazard ratio from a Cox model to a control curve from a parametric model; only the hazard ratio from the chosen parametric model should be applied to its curve.
Sources
Therneau's baseline hazard increment with risk scores
Therneau TM. Software validation. Vignette for the R survival package. Updated December 2022. Section 2 Basic formulas, equation 6, gives the increment as the sum of wi dNi(t) over the sum of Yi(t) wi ri. Table 1 lists the Breslow increments for test data 1. Section 3.1 calls the cumulative baseline hazard the Nelson cumulative hazard estimator with case weights of wi ri, also known as the Aalen and Breslow estimates, and gives the estimated hazard for a subject as exp(xi beta) times the baseline and survival as its negative exponential.
TSD 14 on inference from observed data and Cox hazard ratios on parametric curves
Latimer NR. NICE DSU Technical Support Document 14: Survival analysis for economic evaluations alongside clinical trials, extrapolation with patient-level data. Sheffield: Decision Support Unit, ScHARR, University of Sheffield; June 2011, last updated March 2013. Section 2 says that a Cox proportional hazards regression model bases inferences only upon observed data, and such methods are only likely to be reasonable when data is almost entirely complete, as otherwise they will not produce accurate estimates of mean survival. Section 2.9 says that it is theoretically incorrect to apply a hazard ratio derived from a different parametric model or from a Cox proportional hazards model to the control group survival curve from the chosen parametric model.
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0
