Signature
HR = (d_T / PT_T) / (d_C / PT_C); SE_beta = sqrt(1 / d_T + 1 / d_C)
| Inputs | Definition | Unit |
|---|---|---|
d_T | Number of first events of the named type observed in the treatment arm, above zero | count |
PT_T | Total time at risk in the treatment arm, each person contributing time from the origin to the event or censoring | person-years or another person-time unit |
d_C | Number of first events of the named type observed in the comparator arm, above zero | count |
PT_C | Total time at risk in the comparator arm, in the same unit as PT_T | person-years or another person-time unit |
HR | Treatment event rate divided by the comparator event rate, read as the hazard ratio when both hazards are constant | ratio, no unit |
|---|---|---|
SE_beta | Approximate standard error of the natural logarithm of the rate ratio | log hazard ratio, no unit |
Function
Relative hazard function
Maps the hazards of an event in a treatment group and a comparator group at the same time t to their ratio. Under proportional hazards the ratio is constant over time, and it can then be applied to a baseline survival curve or a baseline transition probability to obtain absolute outcomes for the treatment group.
Computational function
Computational function: hazard ratio, interval and cycle probabilities from event counts and person-time
Takes the counts a trial report or registry extract usually gives, the events and person-time at risk in each arm, with the model's cycle length, and returns everything a cohort model needs from them: the two constant hazards, the hazard ratio (HE-FM-HR-005), its approximate 95% interval (HE-FM-HR-006), and the comparator and treatment probabilities of the event in one cycle (HE-FM-HR-004). The steps are chained, so later outputs use earlier ones. The inputs therefore differ from the formulas' variables: the transition probability formula needs p_C and HR, and the function derives both from the raw counts.
Inputs and outputs:
d_T,d_C: Events in the treatment and comparator arms; required, above zero. Unit: count.;PT_T,PT_C: Person-time at risk in each arm, in the same unit; required, above zero. Unit: person-years.;u: Cycle length in the same time unit as the person-time; required, above zero. Unit: years.;h_T,h_C: Constant hazards. Unit: events per person-year.;HR,HR_L,HR_U: Hazard ratio and its 95% limits. Unit: ratio.;SE_beta: Standard error of the log hazard ratio. Unit: log ratio.;p_C,p_T: Probabilities of the event within one cycle for a person event-free at its start. Unit: probability.Assumption: Both hazards are constant over follow-up and over the modelled cycles, so the exponential model holds in each arm and the hazard ratio is constant. Only one event leads out of the starting state; with competing exits the cause-specific rates are separated first.
Worked example (Article's rates of 0.07 and 0.10 with annual cycles): Seventy and 100 events over 1,000 person-years per arm give a hazard ratio of 0.70 with a 95% interval of about 0.5158 to 0.9501, and annual probabilities of about 0.0952 and 0.0676, as in the article.
d_T = 70; PT_T = 1000; d_C = 100; PT_C = 1000; u = 1; h_T = 0.07; h_C = 0.1; HR = 0.7; SE_beta = 0.155839; HR_L = 0.515757; HR_U = 0.950059; p_C = 0.095163; p_T = 0.067606Worked example (Unequal person-time with quarterly cycles): Forty-two events over 800 person-years and 60 over 750 give a hazard ratio of 0.65625 and quarterly probabilities of about 0.0198 and 0.0130 (computed here for illustration).
d_T = 42; PT_T = 800; d_C = 60; PT_C = 750; u = 0.25; h_T = 0.0525; h_C = 0.08; HR = 0.65625; SE_beta = 0.201187; HR_L = 0.4424; HR_U = 0.973471; p_C = 0.019801; p_T = 0.013039Excel:
=(TreatmentEvents/TreatmentPersonTime)/(ComparatorEvents/ComparatorPersonTime)returns the hazard ratio in RateHR;=EXP(LN(RateHR)-1.96*SQRT(1/TreatmentEvents+1/ComparatorEvents))and the same with a plus sign return the limits in LowerHR and UpperHR; with the cycle length in years in a cell named CycleYears,=1-EXP(-ComparatorEvents/ComparatorPersonTime*CycleYears)returns the comparator probability in CompProb; and=1-(1-CompProb)^RateHRreturns the treatment probability.R:
hr_counts <- function(d_T, PT_T, d_C, PT_C, u, z = 1.96) { h_T <- d_T/PT_T; h_C <- d_C/PT_C; HR <- h_T/h_C; se <- sqrt(1/d_T+1/d_C); p_C <- 1-exp(-h_C*u); c(HR = HR, SE_beta = se, HR_L = exp(log(HR)-z*se), HR_U = exp(log(HR)+z*se), p_C = p_C, p_T = 1-(1-p_C)^HR) }Returns 0.7, 0.155839, 0.515757, 0.950059, 0.095163 and 0.067606 for the first example; given a vector argument, such as several cycle lengths, it returns each output that depends on it once per element (p_C1, p_C2 and so on) in one named vector.Python:
def hr_counts(d_T, PT_T, d_C, PT_C, u, z=1.96): import math; h_T = d_T/PT_T; h_C = d_C/PT_C; HR = h_T/h_C; se = math.sqrt(1/d_T+1/d_C); p_C = 1-math.exp(-h_C*u); return {"HR": HR, "SE_beta": se, "HR_L": math.exp(math.log(HR)-z*se), "HR_U": math.exp(math.log(HR)+z*se), "p_C": p_C, "p_T": 1-(1-p_C)**HR}Returns 0.7, 0.155839, 0.515757, 0.950059, 0.095163 and 0.067606 for the first example.Test (Treatment probability equals the direct conversion of the treatment rate): Because the hazard ratio times the comparator hazard is the treatment hazard, the power form and the direct conversion of the treatment rate agree. Expected result: TRUE. Excel check:
=ABS((1-(1-CompProb)^RateHR)-(1-EXP(-TreatmentEvents/TreatmentPersonTime*CycleYears)))<1E-12Test (Equal rates give a hazard ratio of 1 and an interval around it): When both arms have the same rate the hazard ratio is 1 and the interval contains 1. Expected result: TRUE. Excel check:
=IF(ABS(TreatmentEvents/TreatmentPersonTime-ComparatorEvents/ComparatorPersonTime)<1E-12,AND(ABS(RateHR-1)<1E-12,LowerHR<1,UpperHR>1),TRUE)Common error (Person-time in months with the cycle length in years): If person-time is recorded as 12,000 person-months per arm, the comparator rate is about 0.00833 per person-month, and applying it with u = 1 as if in years gives an annual probability of about 0.0083 instead of 0.0952 (computed here for illustration). The hazard ratio is unaffected, so the error shows only in the absolute probabilities.
Source: Higgins JPT, Li T, Deeks JJ (editors). Chapter 6: Choosing effect measures and computing estimates of effect (last updated August 2023). In: Higgins JPT, Thomas J, Chandler J, Cumpston M, Li T, Page MJ, Welch VA (editors). Cochrane Handbook for Systematic Reviews of Interventions version 6.5. Cochrane; 2024. Section 6.7.1 on rates, the rate ratio and the standard error of its logarithm. Gidwani R, Russell LB. Estimating transition probabilities from published evidence: a tutorial for decision modelers. PharmacoEconomics. 2020;38(11):1153-1164. Table 1 on rates and equation 9 on converting a rate to a probability for a chosen time interval.
h_T = d_T / PT_T; h_C = d_C / PT_C; HR = h_T / h_C; SE_beta = sqrt(1 / d_T + 1 / d_C); HR_L = exp(log(HR) - 1.96 * SE_beta); HR_U = exp(log(HR) + 1.96 * SE_beta); p_C = 1 - exp(-h_C * u); p_T = 1 - (1 - p_C)^HR
Try this function
Implementations
Excel
Person-time hazard ratio and log standard error from named counts
With the event counts in cells named TreatmentEvents and ComparatorEvents and the person-time in TreatmentPersonTime and ComparatorPersonTime, the first formula returns the hazard ratio, held in a cell named RateHR, and the second the standard error of its natural logarithm.
=(TreatmentEvents/TreatmentPersonTime)/(ComparatorEvents/ComparatorPersonTime); =SQRT(1/TreatmentEvents+1/ComparatorEvents)
Assumptions
Constant hazard in each arm over follow-up for the rate ratio
The hazard in each arm stays constant over the follow-up that the person-time covers, as in an exponential model, which is also a proportional hazards model. When the hazards change over time, one rate per arm averages over periods with different hazards, and a model that lets the hazard vary is needed instead.
Events and person-time counted on the same basis in both arms
Both arms count the same event from the same time origin, and a person's time at risk stops at the first event or at censoring. The standard error uses the event counts alone, so it treats the counts as Poisson and needs at least one event in each arm.
Worked examples
Seventy and 100 events over 1,000 person-years per arm
Seventy events over 1,000 person-years on treatment and 100 events over 1,000 person-years on the comparator give rates of 0.07 and 0.10 per person-year, the article's illustrative hazards, so HR = 0.07 / 0.10 = 0.70. The standard error of the log ratio is the square root of 1/70 plus 1/100, about 0.1558 (computed here for illustration).
d_T = 70; PT_T = 1000; d_C = 100; PT_C = 1000; HR = 0.7; SE_beta = 0.1558
Unequal person-time of 800 and 750 person-years
Forty-two events over 800 person-years on treatment and 60 events over 750 person-years on the comparator give rates of 0.0525 and 0.08 per person-year and a hazard ratio of 0.65625, with a standard error of the log ratio of about 0.2012 (computed here for illustration).
d_T = 42; PT_T = 800; d_C = 60; PT_C = 750; HR = 0.65625; SE_beta = 0.2012
Common errors
Dividing event counts instead of event rates
With equal numbers randomised, the second example's counts give 42 / 60 = 0.70, while the rates give 0.65625, because the treatment arm has more person-time at risk (computed here for illustration). A ratio of counts or proportions ignores how long each arm was followed and is not a hazard ratio.
Zero events in one arm of a person-time hazard ratio
With no events in one arm the rate ratio is 0 or undefined and 1 divided by the zero count makes the standard error infinite. The Cochrane Handbook notes that 0.5 may be added to each count in that case, and the correction is reported.
Sources
Rate ratio and standard error of its logarithm in the Cochrane Handbook
Higgins JPT, Li T, Deeks JJ (editors). Chapter 6: Choosing effect measures and computing estimates of effect (last updated August 2023). In: Higgins JPT, Thomas J, Chandler J, Cumpston M, Li T, Page MJ, Welch VA (editors). Cochrane Handbook for Systematic Reviews of Interventions version 6.5. Cochrane; 2024. Section 6.7.1: a rate relates the events to the person-time of follow-up; the rate ratio divides one group's rate by the other's and is analysed on the log scale, with an approximate standard error of the log rate ratio of the square root of 1/E_E plus 1/E_C; 0.5 may be added to each count when there are zero events; the time unit cancels.
Hazard ratio as the ratio of two reported hazard rates
Tierney JF, Stewart LA, Ghersi D, Burdett S, Sydes MR. Practical methods for incorporating summary time-to-event data into meta-analysis. Trials. 2007;8:16. Section 1: when a hazard rate is reported for each arm, the two rates replace the numerator and denominator of equation 5, so the hazard ratio is the research-arm rate divided by the control-arm rate (1.21 and 0.80 give 1.51).
Exponential model as a constant-hazard proportional hazards model
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.1: the exponential distribution has a hazard that is constant over time, survivor function exp(minus lambda t), and is a proportional hazards model whose treatment effect is a hazard ratio.
Event rate as events divided by total time at risk
Gidwani R, Russell LB. Estimating transition probabilities from published evidence: a tutorial for decision modelers. PharmacoEconomics. 2020;38(11):1153-1164. Table 1 and the section on rates: a rate is the number of events in a period divided by the total time experienced by all subjects followed (40 deaths over 320 person-years give 0.125 per person-year).
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0