Choosing an analysis for time-varying treatment
Choose time-varying treatment methods by the target strategy, the timing of treatment decisions and whether earlier treatment changes later confounders.
Fit
When it matters, and when it does not
It matters when
- Treatment starts, stops or changes dose during follow-up, such as a drug begun months after diagnosis.
- You want the effect of a treatment strategy kept up over time, such as always treating against never treating.
- A marker, such as a laboratory value, both guides later treatment and predicts the outcome.
It matters less when
- Treatment is fixed at time zero. Consider baseline adjustment or propensity methods, with a causal model and measured confounders. Read: Choosing propensity matching or weighting
- The reasons clinicians changed treatment were never recorded. No method can recover them, so plan a sensitivity analysis. Read: Sensitivity analyses
Before you start
What to check in your study
- The treatment strategies you comparetargetSuch as start within a grace period, always treat, or never treat. Define when each strategy can first be distinguished.
- Time zero, the same for every strategySuch as diagnosis. Eligibility and follow-up start there, never on the day treatment began.
- The factors recorded before each treatment decisionEverything that drives the next decision and also predicts the outcome, such as a laboratory value.
- The outcome, and the date of every treatment changeoutcomeTypecompetingEventsOften a time to an event, such as stroke. Each change splits the patient's follow-up.
- The method, if a marker feeds back on treatmentChoose a marginal structural model for feedback, time-varying Cox for an appropriate current-exposure question, or clone-censor-weight for initially compatible strategies.
- At every time, the recorded factors explain who changes treatment.How to check: This cannot be tested. List why clinicians change treatment, and check each reason is recorded before the change.
- At every time, each kind of patient could follow either strategy.How to check: Look at the weights. Very large weights mean some patients almost never follow one strategy.
- The models the method relies on are close enough to right.How to check: Weighting relies on models for treatment and for censoring. The g-formula relies on models for the factors and the outcome.
- With no feedback, a Cox model still needs every confounder.How to check: Splitting follow-up fixes the timing of exposure, not confounding. Choose confounders from a causal diagram.
Plain language
How it works
First decide whether the question concerns current exposure or a treatment strategy over time. Then ask whether earlier treatment changes a factor that guides later treatment. That feedback can invalidate ordinary adjustment. Marginal structural models address measured feedback under strong causal assumptions; the single-method article explains the weighting.
Consider time-varying Cox when its current-exposure question and confounding assumptions fit. Consider clone-censor-weight when people initially fit several strategies, such as starting treatment within a grace period. It can use the same weighting principles as a marginal structural model. Misclassifying earlier untreated time creates immortal time bias, which makes a treatment look protective. None of these choices fixes unmeasured confounding.
Worked example
A worked example
- Setting
- 1,000 adults discharged after a heart attack, followed for up to three years. 400 start a new drug at some point after discharge.
- Question
- Is taking the drug linked to fewer deaths?
- Approach
- Each starter's follow-up is split on the day they start. Their 200 person-years before starting count as unexposed. The 600 who never start give 1,000 person-years.
- Result
- There were 40 deaths in 800 exposed person-years, 5 per 100, and 120 in 1,200 unexposed person-years, 10 per 100. That is a rate difference of -5 per 100 person-years and a crude rate ratio of 0.5.
- What it means
- Counting starters as exposed from discharge would give 4 deaths per 100 person-years against 12, a ratio of a third. That gap is immortal time. The 0.5 is still crude and needs adjusting for confounders.
In practice
Recent studies PubMed search · not vetted
Watch out
Common mistakes
The one to remember
When a variable is both a confounder of later treatment AND affected by earlier treatment, adjusting for it in the usual way is wrong in BOTH directions: leaving it out leaves confounding, and putting it in a regression blocks part of the effect you are trying to measure and can open a collider path. This is not a subtlety at the margins: in the zidovudine study that illustrated marginal structural models, adjusting only for baseline factors gave a mortality rate ratio of 2.3, while weighting for the time-varying CD4 count as well gave 0.7, with a conservative 95% interval of 0.6 to 1.0. The other trap is assigning exposure retrospectively, which creates immortal time.
- Using the standard errors a weighted model prints by default.Instead: Use robust errors, or bootstrap people and refit the weight models in every resample.
- Trimming or capping large weights without saying so.Instead: Report the spread of the weights, and name any trimming rule in advance. Trimming changes the population the effect describes.
- Reading a hazard ratio for current use as the effect of a strategy over time.Instead: A time-varying Cox model compares current use with no current use. For always against never treating, use a marginal structural model or the g-formula.
- Building weights from factors measured after the treatment decision they explain.Instead: Use only factors recorded before each decision. A later factor may already reflect the treatment.
Inside Mallard
How Mallard uses this
Learn search lists Choosing an analysis for time-varying treatment. Related methods explain time-varying Cox, marginal structural models and clone-censor-weight analyses.
concept.choosing_time_varying_treatment, the id a plan cue records.Related Learn pages
Related designs and methods
Evidence
Sources & further reading
- Marginal structural models and causal inference in epidemiology (opens in a new tab) · Epidemiology · doi 10.1097/00001648-200009000-00011
- Marginal structural models to estimate the causal effect of zidovudine on the survival of HIV-positive men (opens in a new tab) · Epidemiology · doi 10.1097/00001648-200009000-00012
- Immortal time bias in pharmaco-epidemiology (opens in a new tab) · Am J Epidemiol · doi 10.1093/aje/kwm324
- Methods for dealing with time-dependent confounding (opens in a new tab) · Stat Med · doi 10.1002/sim.5686