Denominators Can Learn the Future
A treatment cannot save you before it starts.
That sentence is so obvious that it sounds useless. But a large class of observational survival analyses violates it. The violation is quiet. It happens in the denominator.
Call someone “treated” if they ever receive a drug, adopt a feature, enter a program, or switch to a new execution strategy during follow-up. Then compare their survival from day zero with people who never receive it. The treated group will often look better, even when the treatment has no effect at all, because each treated person had to survive long enough to become treated.
That pre-treatment span is called immortal time: by construction, the outcome could not have occurred during that span for people who end up classified as treated.1 If it had occurred, they would not have become treated.
The bug is not “survival analysis is hard.” The bug is that treatment status was learned after time zero and then projected backward to time zero.
The Denominator Learned the Future
Suppose follow-up starts at (t=0). Person (i) has an event time (Y_i), a censoring time (C_i), and a treatment start time (T_i). A naive analysis defines
\[A_i^{\mathrm{ever}} = \mathbf{1}\{T_i < \min(Y_i, C_i)\}.\]This is already suspicious. The exposure label uses future information. The person is called “treated” at baseline because a later treatment start was observed.
If that person is followed for (Y_i) months and treatment starts at (T_i), the naive treated denominator contains
\[\underbrace{T_i}_{\text{pre-treatment, no event possible for future treated}} + \underbrace{(Y_i - T_i)}_{\text{actual treated follow-up}}.\]The first term is not treated time. It is untreated survival time that has been credited to the treated group. Worse, it is event-free by definition among people who become treated. That denominator has stolen a clean stretch of survival from the past and used it to lower the treated event rate.
The corrected time-dependent exposure is
\[A_i(t)=\mathbf{1}\{t \ge T_i\}.\]Before (T_i), the person contributes untreated time. After (T_i), the person contributes treated time. That does not solve every causal problem: confounding, treatment selection, censoring, adherence, and competing events still matter. But it fixes this accounting error.
The error has a famous medical name, but the pattern is much broader:
"users who adopted the feature" survived until adoption
"orders that used smart routing" survived until routing was triggered
"accounts that upgraded" survived until upgrade
"players who joined the guild" survived until joining
If the group label is assigned by a future milestone, the analysis has a time-zero problem.
A Small Accounting Lab
The lab below simulates a cohort with a known truth. The default treatment has no causal effect: the true hazard ratio is 1.00. Some subjects start treatment later, some have an event before they ever get there, and everyone is administratively censored at the end of follow-up.
Three estimates are shown:
- Naive ever-treated rate ratio: classify people by whether they ever start treatment, then count all follow-up from time zero in that group.
- Time-dependent rate ratio: split each person’s follow-up into untreated time before treatment and treated time after treatment.
- Landmark rate ratio: pick a month, keep only people still event-free at that month, classify treatment status by then, and analyze from that point onward.
I audited the simulator before rewriting. In the default no-effect cohort, the naive ever-treated rate ratio is 0.480, while the time-dependent rate ratio is 0.991 and the landmark estimate is 0.968. Future-treated subjects contribute 13,258 months of immortal pre-treatment time and 24,046 months of actual treated time, so 35.5% of the naive treated denominator is not treated time at all. When the true treatment HR is set to 1.30, the time-dependent estimate is 1.293 but the naive estimate still looks protective at 0.595. A 3,888-case sweep found the expected bias pattern in no-effect settings and many harmful-treatment settings where the naive estimate crossed below 1; late landmark settings with no treated person-time correctly return no rate ratio. I also fixed the lab UI so displayed slider values are synchronized to the cleaned follow-up, landmark, and treatment parameters.
Deterministic synthetic cohort. The default has no treatment effect and no baseline risk heterogeneity, so the time-dependent estimate should hover near the true hazard ratio while the naive ever-treated analysis invents a benefit from future information.
Start at the default. The true hazard ratio is 1.00. The time-dependent rate ratio is close to 1.00. The naive ever-treated rate ratio is much lower, around 0.5 in this deterministic run. Nothing causal happened; the naive analysis gave the treated group credit for event-free time before treatment started.
The person-time ledger is the main exhibit. The naive treated denominator is split into two colors. One part is actual treated time. The other part is immortal pre-treatment time. That orange piece has no treated events because, for future-treated people, an event before treatment would have moved them out of the future-treated group.
Now raise Median start delay. The longer people must wait to become treated, the more event-free pre-treatment time can be misclassified. Suissa’s review makes the same point analytically: the magnitude of the rate-ratio bias increases with the duration of immortal time, and can depend on the shape of the outcome hazard.1
Next set True treatment HR to 130%. The treatment is now harmful. The naive analysis may still make it look protective or nearly neutral because the immortal denominator is pushing in the opposite direction. This is the dangerous case: a bad strategy can look good because it starts late.
Finally raise Risk heterogeneity and move Timing selection. If high-risk subjects start earlier or later, the time-dependent accounting fix is no longer the whole causal solution. You have removed the immortal-time misclassification, but you still need a design and adjustment strategy for confounding by treatment timing. This is why the right answer is not “always run a time-dependent Cox model.” The right answer is “specify the trial you wish you had run.”
The source is here:
assets/js/immortal-time-lab.js.
The Statin Example Is a Warning Label
Lévesque, Hanley, Kezouh, and Suissa’s BMJ paper is the canonical short case-file.2 They revisited an observational study of statins and diabetes progression. In the time-fixed analysis, people classified as statin users carried all their follow-up time in the statin-user group, including the time before they actually satisfied the exposure definition. In their time-dependent analysis, person-days were untreated until the definition was met and treated thereafter.
The result flipped the story. The time-fixed Cox analysis produced an adjusted hazard ratio of 0.74, suggestive of benefit. The time-dependent analysis produced 1.97. In the Poisson accounting table, immortal and untreated periods were about two thirds of the follow-up allocated to statin users in the biased analysis. The authors also ran the same design with drug classes that should not plausibly prevent diabetes progression; the apparent protective associations disappeared after correcting the immortal time.
That is what makes the bias unsettling. It can manufacture biological-looking effects from administrative timing.
Why Landmarking Helps, But Changes the Question
A landmark analysis chooses a time (L), keeps only those still event-free at (L), classifies exposure status using information available up to (L), and then analyzes outcomes after (L). It is often simple and visually convenient: after the landmark, treatment status can be treated as fixed for that landmark-defined population.
But it answers a conditional question:
among people who survived event-free until L,
what is the association of treatment status by L with later outcome?
That may be exactly the desired question. Or it may be a compromise. A late landmark throws away early events. An early landmark may leave too few treated subjects. Simulation work comparing guarantee-time-bias remedies generally finds that time-dependent models and landmark analyses can both help, but the landmark’s performance depends on the chosen landmark and the scientific question.3
The lab’s landmark estimate moves around for the same reason. It is not a universal correction; it is a new estimand.
Target Trial First, Model Second
Hernán and Robins describe observational causal analyses as attempts to emulate a target trial: the randomized experiment we would have run if it were available.4 For immortal time, the target-trial habit is especially useful because it forces a synchronization:
eligibility
treatment assignment
start of follow-up
If those three clocks do not align, the analysis is already in trouble.
Hernán, Sauer, Hernández-Díaz, Platt, and Shrier make this point directly in their paper on target-trial specification: immortal time and related “self-inflicted injuries” arise when follow-up, eligibility, and treatment assignment are not aligned.5 A newer structural description by Hernán and coauthors sharpens the language further: the phrase “immortal time bias” can make it sound as if the immortal interval itself is the cause, but the underlying source is usually selection or misclassification based on post-baseline information.6
That distinction is worth keeping. The time interval is the symptom. The future-dependent rule is the disease.
A Production Checklist
Before trusting a survival comparison involving adoption, treatment, activation, upgrade, routing, escalation, or any other post-baseline milestone, I would ask:
- What is time zero?
- Could every group member have been assigned to their strategy at time zero?
- Was treatment status defined using information after time zero?
- Are pre-treatment person-days counted as treated?
- Are treated and untreated follow-up starts aligned?
- If there is a grace period, is it part of the strategy definition?
- Are people cloned/censored/weighted, landmarked, or modeled with time-dependent exposure for a reason tied to the target trial?
- What events were lost before someone could become treated?
- What estimand does the analysis actually answer?
This checklist applies outside medicine. Product analytics has the same trap when “users who adopted feature X” are compared with “users who never adopted feature X” from account creation. Quant research has the same trap when a strategy is credited for surviving until a trigger fires. Gaming telemetry has the same trap when guild membership, ranked placement, or tutorial completion is treated as a baseline attribute.
The future is allowed to explain the future. It is not allowed to relabel the past.
A Thread Worth Pulling
The interesting engineering problem is not only estimating one time-dependent effect. It is building analysis systems that make the impossible denominator hard to write.
A survival analytics layer should know whether a covariate is baseline, time-varying, delayed, or defined by future behavior. It should require an explicit time-zero contract before producing a Kaplan-Meier curve, hazard ratio, retention lift, or product adoption comparison. It should display the person-time ledger by default:
untreated time
actual treated time
immortal or grace-period time
censored time
event counts by exposure state
The statistical lesson is old. The systems lesson is still underbuilt. Most bad analyses are not written by people trying to cheat. They are written by people whose tools make the future label look like an ordinary column.
-
Samy Suissa, “Immortal Time Bias in Pharmacoepidemiology”, American Journal of Epidemiology, 2008. ↩ ↩2
-
Linda E. Lévesque, James A. Hanley, Abbas Kezouh, and Samy Suissa, “Problem of immortal time bias in cohort studies: example using statins for preventing progression of diabetes”, BMJ, 2010. ↩
-
In Sung Cho and coauthors, “Statistical methods for elimination of guarantee-time bias in cohort studies: a simulation study”, BMC Medical Research Methodology, 2017. ↩
-
Miguel A. Hernán and James M. Robins, “Using Big Data to Emulate a Target Trial When a Randomized Trial Is Not Available”, American Journal of Epidemiology, 2016. ↩
-
Miguel A. Hernán, Brian C. Sauer, Sonia Hernández-Díaz, Robert W. Platt, and Ian Shrier, “Specifying a target trial prevents immortal time bias and other self-inflicted injuries in observational analyses”, Journal of Clinical Epidemiology, 2016. ↩
-
Miguel A. Hernán, Jonathan A. C. Sterne, Julian P. T. Higgins, Ian Shrier, and Sonia Hernández-Díaz, “A structural description of biases that generate immortal time”, Epidemiology, 2025; advance online 2024. ↩