Cox hazard ratio that changes with log time through a covariate interaction

Adding an interaction between a covariate and log time lets the log hazard ratio change along a straight line in log time, so the covariate's effect is no longer constant. b_0 is the coefficient of the covariate and b_1 the coefficient of its interaction with log time. At t = 1 in the units of the fit the log time term vanishes, so exp(b_0) is the hazard ratio at that one time and not an average. HE-FM-HR-002 is the special case b_1 = 0. The form is a way of handling non-proportional hazards within a Cox model, and a covariate whose value changes during follow-up is a separate idea.

Signature

beta_t = b_0 + b_1 * log(t); HR_t = exp(beta_t)
Inputs
InputsDefinitionUnit
b_0Fitted coefficient of the covariate, the log hazard ratio at t = 1log hazard ratio, no unit
b_1Fitted coefficient of the covariate times log time, the change in the log hazard ratio per unit of log timelog hazard ratio per unit of log time
tTime since the origin, above zero, in the units used in the fityears in the Bradburn example
Output
beta_tLog hazard ratio at time t for a one-unit increase in the covariatelog hazard ratio, no unit
HR_tHazard ratio at time t for a one-unit increase in the covariateratio, no unit

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 hazard ratio with a log time interaction

    With CoefMain, CoefLogTime and FollowUpTime as inputs, the formulas go in LogHazardRatioAtTime and HazardRatioAtTime.

    =CoefMain+CoefLogTime*LN(FollowUpTime); =EXP(LogHazardRatioAtTime)

Assumptions

  • Log hazard ratio linear in natural log time within follow-up

    The effect is taken to change as a straight line in the natural log of time, and t must be above zero, since Excel's LN(0) returns #NUM!. The line is fitted within follow-up and says nothing about times beyond it. Other time functions give other shapes.

  • Time in the same units as the Cox fit

    b_0 depends on the time unit, because moving to months subtracts b_1 log(12) from it, while b_1 and the hazard ratio at any given moment stay the same (derived).

Worked examples

  • Absence of ascites at 2 years in the Bradburn ovarian cancer model

    Coefficients from Table 4 of Bradburn and colleagues. The result rounds to their 0.74 at 2 years.

    b_0 = -0.466; b_1 = 0.233; t = 2; beta_t = -0.3045; HR_t = 0.7375
  • Absence of ascites at 5 years in the Bradburn ovarian cancer model

    The same coefficients at 5 years. The result rounds to their 0.91, so the hazard ratio has moved towards 1.

    b_0 = -0.466; b_1 = 0.233; t = 5; beta_t = -0.091; HR_t = 0.913
  • Absence of ascites at 1 year returns the main Cox coefficient

    A limiting case. At t = 1 the log time term is zero, and the hazard ratio is the 0.63 printed in the absence of ascites row of Table 4.

    b_0 = -0.466; b_1 = 0.233; t = 1; beta_t = -0.466; HR_t = 0.6275
  • Endometroid histology at 5 years in the Bradburn ovarian cancer model

    The endometroid row and its interaction with log time in Table 4. The hazard ratio is 1.37 at 1 year and 0.61 at 5 years, passing through 1 at exp(0.624), about 1.87 years (derived).

    b_0 = 0.312; b_1 = -0.5; t = 5; beta_t = -0.4927; HR_t = 0.611

Common errors

  • Reading the main coefficient as the overall hazard ratio

    In Table 4 of Bradburn and colleagues the absence of ascites row shows a hazard ratio of 0.63. That applies at t = 1 only; at 5 years the model gives 0.91. Quoting 0.63 for the whole of follow-up overstates the effect at later times.

  • Entering time in other units than the Cox fit

    The Bradburn coefficients are fitted with time in years. Entering 24 for 2 years gives exp(-0.466 + 0.233 log(24)), about 1.32 against 0.74, so the sign of the effect appears to reverse.

Sources

  • Bradburn and colleagues on time-dependent effects with log time

    Bradburn MJ, Clark TG, Love SB, Altman DG. Survival analysis part III: multivariate data analysis, choosing a model and assessing its adequacy and fit. British Journal of Cancer. 2003;89(4):605-611. Section Assessing whether PH is appropriate says that a Cox model with interaction terms between the covariates and (log) time allows the effect to change with time. The text prints exp(-0.466 + 0.233 x log(2)) = 0.74 at 2 years and exp(-0.466 + 0.233 x log(5)) = 0.91 at 5 years. Table 4 prints absence of ascites -0.466, ascites x log(time) 0.233, endometroid 0.312 and endometroid x log(time) -0.500.

    View source →

  • PMG36 sections 4.6.22 and 4.6.24 when hazard ratios change over time

    National Institute for Health and Care Excellence. NICE technology appraisal and highly specialised technologies guidance: the manual (PMG36). Published 31 January 2022, last updated 13 October 2026. Section 4.6.22 states that hazard ratios may either be constant over time or change over time, and that the proportional hazards assumption should always be assessed. Section 4.6.24 states that if the assumption does not hold in some of the studies, alternative methods should be considered, as described in technical support document 21.

    View source →

Canonical Identity

This formula is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Author: Dr Darrin Baines · Publisher: Intelligent Parameters Ltd · Identifier: https://healtheconomics.wiki/formula/cox-hazard-ratio-that-changes-with-log-time-through-a-covariate-interaction