Adjusting for Time-Varying Confounding in Longitudinal Studies

5 minute read

Published: September 8th, 2025

Introduction

Real-world data (RWD) can provide insight into treatment effects in a real-world setting. However, because treatment allocation in RWD is not random, analyses are susceptible to confounding, when a variable influences both treatment and outcome, potentially biasing results.

When the exposure of interest varies over time, there may be time-varying confounding. Key confounders can change over time, sometimes in response to earlier treatment (i.e., a result from a laboratory test) impacting subsequent treatment. This is known as time-varying confounding. Conventional methods such as generalized linear models, or propensity score matching provides biased effects. Time-varying confounding requires a different analytical approach.

This blog describes what time-varying confounding is, why traditional methods lead to biased results, and the advanced techniques available to address it. It explains when time-varying confounding is likely to occur, why it matters for study validity, and three approaches to adjust for it.

Why Time-Varying Confounding Matters in Clinical Trials

Time-varying confounding can occur in clinical trials with long-term follow-up or repeated measurements. Examples include:

  • Disease progression markers (e.g., tumor size, biomarker levels) that change during the trial and may influence subsequent treatment decisions.
  • Safety parameters such as blood pressure or liver function tests, which respond to treatment and can trigger dose modifications or discontinuations.
  • Concomitant medication use, which can vary over time and impact both treatment exposure and trial outcomes.
  • If time-varying confounding is not addressed, standard analyses can yield misleading estimates of treatment effect—potentially influencing key trial decisions, regulatory review, and post-approval commitments.

The Problem: How Time-Varying Confounding Differs

Time-varying confounding arises when both exposures and confounders change over time, and when treatment influences future confounders. [1]

For example, a biomarker might improve after initial treatment but still factor into decisions about whether to adjust therapy later on. If this time-varying confounder is simply included as a time-dependent covariate in a conventional model, such as a time-dependent Cox regression, random effects model, or generalized estimating equation the result may be biased. [1]

The Solution: Methods for Addressing Time-Varying Confounding

Several causal inference methods have been developed to address this problem, particularly when confounders are influenced by prior treatment. Three commonly used methods include:

1.Inverse-Probability Weighting (IPW) via Marginal Structural Models (MSMs)

Creates a pseudo-population in which treatment assignment at each time point is independent of measured confounders. [2]

Conceptually similar to propensity score weighting, but applied repeatedly across time.

2. Parametric G-Formula

Simulates the distribution of exposure, confounders and outcome that would have been observed under two scenarios: 1) where every participant received the exposure of interest, 2) where every participant did not receive the exposure of interest.

Averages the confounder-specific mean outcomes under a specific treatment over the joint distribution of confounders over time [1]

3.G-Estimation

Uses two models: a model for the exposure and a semiparametric structural mean model.

G-estimation uses both of these models together to find a situation that makes the exposure independent of the estimated outcome given previous treatment and confounder history [1]

Conclusion

When exposures and confounders both changes over time, and when past treatment can influence future confounders, traditional adjustment methods provide biased results. Methods such as MSMs, the parametric g-formula, and g-estimation are useful alternatives, helping to produce more accurate results for decision-making.

At Phastar, we apply advanced statistical approaches to tackle challenges like time-varying confounding, ensuring that real-world and longitudinal clinical trials generate trustworthy evidence for clinical and regulatory use.

References

1.Mansournia, M. A., Danaei, G., Forouzanfar, M. H., Mahmoodi, M., & Jamali, M. (2017). Handling time varying confounding in observational research. BMJ, 359, j4587. https://pubmed.ncbi.nlm.nih.gov/29038130

2.Hernán, M.A., & Robins, J.M. (2020). Causal Inference: What If. Chapman & Hall/CRC. Causal Inference: What If (the book) — Miguel Hernán

3. Hernán, M. A., Cole, S. R., Margolick, J., Cohen, M., & Robins, J. M. (2005). Structural accelerated failure time models for survival analysis in studies with time-varying treatments. Pharmacoepidemiology and Drug Safety, 14(7), 477–491. https://doi.org/10.1002/pds.1064

Related articles

Rethinking Performance: How to Measure Success in Flexible Biometrics FSP Solutions 

Rethinking Performance: How to Measure Success in Flexible Biometrics FSP Solutions 

August 10th, 2026 4 minute read

As the functional service provider biometrics model evolves, so too must the way sponsors measure its success. Tradit...

Meet the Team: Debreena Chatterjee, Strategic Engagement Director 

Meet the Team: Debreena Chatterjee, Strategic Engagement Director 

August 6th, 2026 6 minute read

In our “Meet the Team” series, we highlight the talented individuals who drive Phastar’s success. Each te...

When Do Flexible Biometrics FSP Solutions Work Best in Clinical Development? 

When Do Flexible Biometrics FSP Solutions Work Best in Clinical Development? 

July 27th, 2026 3 minute read

As clinical trials become more complex, global, and data-intensive, biopharma organizations are under pressure to del...