Resource

When Standard Regression Fails: A Practical Guide to Time-Varying Confounding

Repeated measurements alone do not make standard regression inappropriate. This Resource explains when treatment-confounder feedback creates a more difficult longitudinal causal problem, why conventional adjustment can fail, and when methods such as inverse probability weighting and marginal structural models may be appropriate.

Repeated measurements do not automatically create a difficult causal problem. Repeated treatment or exposure decisions, however, can.

The critical situation arises when a variable measured during follow-up predicts subsequent treatment and the outcome, while also being affected by earlier treatment. The same variable is then simultaneously part of the evolving confounding structure and a consequence of previous treatment. Hernán and Robins call this treatment-confounder feedback and show that traditional confounding-adjustment methods can be biased in this setting (Hernán & Robins, 2020).

Central practical message: Time varying confounding is not simply a repeated-measures problem. The specific difficulty arises when the covariate history needed to control confounding is itself affected by previous treatment or exposure.

That distinction determines whether ordinary regression remains reasonable or whether a longitudinal causal method such as inverse probability weighting of a marginal structural model is needed.

Start With the Causal Question, Not the Regression Model

Suppose treatment or exposure can change over follow-up:

A0, A1, …, AK

and covariates are also repeatedly measured:

L0, L1, …, LK.

The causal target may concern the outcome that would occur under an entire treatment strategy rather than the effect of one isolated exposure measurement. For example, the scientific contrast might compare two sustained treatment strategies or two sequences of exposure decisions.

For causal inference with time-varying treatments, Hernán and Robins formulate longitudinal versions of the familiar identification conditions. Under sequential exchangeability, positivity, and consistency, counterfactual outcomes under treatment strategies can be identified using methods that appropriately incorporate treatment and covariate history, including the g-formula, inverse probability weighting, and g-estimation (Hernán & Robins, 2020).

The first analytical decision is not: “Which regression should I fit?”

It is: What treatment strategy or exposure history am I trying to compare?

What Is Time Varying Confounding?

A time-varying confounder is a variable whose value changes over follow-up and is relevant to confounding treatment at a subsequent time.

Consider the longitudinal ordering:

A0L1A1Y

If L1 predicts both A1 and Y, then L1 may confound the effect of treatment at time 1.

That alone does not yet capture the hardest problem. The crucial additional feature is:

A0L1

Now the later confounder is itself affected by earlier treatment.

Hernán and Robins emphasize that, with time-varying treatments, a confounder for subsequent treatment can lie on a causal pathway from past treatment to the outcome. Whether adjustment introduces bias then depends on the adjustment method; traditional stratification can induce bias, whereas appropriately specified g-methods are designed for this structure (Hernán & Robins, 2020).

Lash et al. describe the same substantive difficulty in settings involving repeated exposure. For example, when a time-varying factor is both a confounder of later exposure and an intermediate consequence of earlier exposure, standard regression adjustment for that factor need not yield an unbiased estimate of the exposure effect (Lash et al., 2021).

The treatment-confounder feedback loop

Earlier treatment → later covariate → later treatment

The later covariate also predicts the outcome.

Thus:

  • earlier treatment changes a later covariate;
  • that covariate helps determine subsequent treatment;
  • the covariate also predicts the outcome;
  • subsequent treatment may itself alter later covariates again.

This feedback can repeat across many treatment occasions.

The result is a causal problem that cannot generally be solved by simply entering every measured covariate into an ordinary outcome regression.

Why Conventional Adjustment Can Fail

Researchers familiar with regression often see the apparent solution immediately:

“If L1 confounds A1, just adjust for L1.”

The problem is that L1 is also downstream of A0.

Conditioning on L1 can eliminate confounding of later treatment while simultaneously introducing bias into estimation of the effect of earlier treatment. Hernán and Robins show that, under treatment-confounder feedback, stratification on a confounder affected by previous treatment can induce an association between previous treatment and the outcome that does not have the desired causal interpretation (Hernán & Robins, 2020).

This is why the familiar rule “adjust for the confounder” becomes inadequate.

Do not adjust for the later confounder

Subsequent treatment remains confounded.

Adjust conventionally for the later confounder

The analysis conditions on a consequence of previous treatment and can introduce bias for the treatment history of interest.

Hernán and Robins demonstrate that traditional adjustment methods can produce non-null estimates even in settings constructed so that the time-varying treatment has no causal effect. They introduce g-methods specifically as solutions for treatment-confounder feedback (Hernán & Robins, 2020).

When Standard Regression May Still Be Appropriate

The presence of repeated observations does not by itself invalidate regression.

Standard regression may remain appropriate for a causal question when the covariates required for confounding control are not consequences of earlier treatment in the problematic way, assuming the other requirements for causal interpretation and the regression model itself are adequately satisfied.

For example, Lash et al. note that the amount of historical adjustment needed depends on the actual causal structure. Prior exposure need not always be controlled if it does not independently affect the outcome through relevant pathways; which earlier variables require adjustment depends on how exposure and outcome histories affect subsequent variables (Lash et al., 2021).

Hernán and Robins likewise distinguish simpler causal settings from complex longitudinal ones. Conventional outcome regression can work in simpler settings but is not generally designed for the complications created by time-varying treatments and treatment-confounder feedback (Hernán & Robins, 2020).

Diagnostic question: Is any variable I need to adjust for to control later confounding itself affected by earlier treatment or exposure?

If the answer is no, ordinary regression may still be a reasonable adjustment method.

If the answer is yes, the analysis has entered the treatment-confounder feedback setting for which conventional adjustment can fail.

Longitudinal Correlation Is a Different Problem

Time varying confounding should not be confused with within-subject correlation.

Longitudinal data typically contain repeated outcomes from the same individual. Those measurements are correlated. Longitudinal models therefore need to account appropriately for dependence among repeated observations.

Fitzmaurice et al., for example, describe longitudinal models in which subject-specific random effects account for correlation among repeated measurements (Fitzmaurice et al., 2011).

That is a statistical dependence problem.

Treatment-confounder feedback is a causal adjustment problem.

A mixed-effects model, GEE, or another repeated-measures model can address within-person correlation without solving time varying confounding. Conversely, a causal weighting strategy does not eliminate the need to account appropriately for the longitudinal outcome structure.

Two distinct questions in longitudinal analysis
Diagnostic question Problem being addressed
Are repeated observations from the same participant correlated? Longitudinal dependence
Does earlier treatment affect a later covariate that influences later treatment and outcome? Time varying confounding / treatment-confounder feedback

A dataset can have one problem, both problems, or neither. Accounting for repeated-measures dependence and addressing causal confounding are separate analytical tasks.

The Core Alternative: Inverse Probability Weighting

One g-method for treatment-confounder feedback is inverse probability weighting (IPW).

The basic idea is to weight each observed treatment history according to the inverse probability of receiving that history given the relevant measured history.

For time-varying treatment, Hernán and Robins generalize treatment weights across treatment occasions. The denominator incorporates the probability of the treatment actually received at each time conditional on previous treatment and covariate history (Hernán & Robins, 2020).

Conceptually, a person who followed a treatment history that was relatively unlikely given their measured history receives more weight than a person whose treatment history was highly predictable.

The purpose is not merely to “control for covariates” inside the outcome model. Instead, weighting constructs a different population in which the treatment assignment mechanism has been altered.

What Is the Pseudo-Population?

The weighted dataset is often described as a pseudo-population.

For ordinary treatment IPW, Hernán and Robins explain that individuals are weighted inversely to their probability of receiving their observed treatment. Under the required exchangeability conditions, treatment becomes independent of the measured confounders in the pseudo-population, so that the treatment-outcome association in that weighted population can have a causal interpretation (Hernán & Robins, 2020).

For time-varying treatment, the same idea is extended across treatment occasions. When the identification conditions hold, longitudinal IP weights create a pseudo-population in which treatment probabilities at each time are no longer determined by the measured covariate history in the way they were in the original observational population (Hernán & Robins, 2020).

The pseudo-population should be understood as a weighted representation of the observed population, not as a new sample of real participants.

Its purpose is to create a setting in which comparisons across treatment strategies are no longer confounded by the measured treatment-predicting covariate history, under the required assumptions.

Marginal Structural Models: Modeling the Causal Contrast

After weighting, researchers commonly fit a marginal structural model (MSM).

A marginal structural model describes the marginal mean of a counterfactual outcome under specified treatment values or strategies. Hernán and Robins distinguish these models from ordinary outcome regressions because the outcome appearing conceptually in the structural model is the counterfactual outcome rather than simply the observed conditional outcome (Hernán & Robins, 2020).

For a simple dichotomous treatment, for example, a marginal structural mean model can represent:

E(Ya) = β0 + β1a

Here β1 represents the average causal contrast between the counterfactual mean outcomes under the treatment levels represented by a, under the required identification and modeling conditions.

The model cannot be fitted directly to counterfactual outcomes because only the outcome corresponding to the treatment actually received is observed for each person. IP weighting supplies the bridge: the structural causal parameter can be estimated by fitting an appropriate weighted associational model in the pseudo-population (Hernán & Robins, 2020).

For longitudinal causal inference, the treatment variable in the MSM can represent a treatment history or strategy, rather than a single baseline treatment.

Stabilized and Nonstabilized Weights

Hernán and Robins directly distinguish nonstabilized and stabilized IP weights for time-varying treatments.

For longitudinal nonstabilized treatment weights, the contribution at each treatment occasion is based on the inverse probability of the treatment actually received conditional on previous treatment and measured covariate history. Stabilized weights retain that denominator but include a numerator based on treatment probabilities conditional on past treatment history (Hernán & Robins, 2020).

Nonstabilized weights

Under the required identification conditions, weighting creates a pseudo-population in which treatment probabilities at each time are constant.

Stabilized weights

Treatment probabilities may depend on past treatment history but not on the measured covariate history used for confounding adjustment.

Hernán and Robins also note an efficiency motivation for stabilization: stabilized weights can yield narrower confidence intervals than nonstabilized weights in nonsaturated weighted models, and time-varying treatment settings are among those in which stabilized weights are used (Hernán & Robins, 2020).

The practical point is not to choose a weighting formula mechanically. The numerator and denominator must correspond to the causal estimand and the intended weighted population.

The Three Identification Conditions You Cannot Weight Away

Inverse probability weighting does not create causal identification from assumptions that are scientifically implausible.

For time-varying treatments, three conditions are central.

1. Sequential exchangeability

At each treatment decision, treatment assignment must be exchangeable with the relevant counterfactual outcomes conditional on the measured treatment and covariate history required for adjustment.

In observational data, this means the measured history must be sufficient for the intended confounding control. Weighting cannot remove confounding by variables that were not adequately measured and incorporated.

Hernán and Robins explicitly identify sequential exchangeability as part of the identification framework for causal effects of time-varying treatment strategies (Hernán & Robins, 2020).

2. Positivity

Among the treatment and covariate histories relevant to the target population, the treatment strategies being compared must remain possible.

For a simpler treatment setting, Hernán and Robins define positivity as requiring a positive probability of each treatment value involved in the causal contrast within covariate strata that occur in the target population. Without such observations, the data provide no empirical information about the missing treatment alternative in that stratum (Hernán & Robins, 2020).

The same principle extends sequentially to time-varying treatment.

Severe practical positivity problems are also visible through weighting: treatment histories with very small estimated probabilities generate very large inverse probability weights.

3. Consistency

The observed outcome under the treatment actually received must correspond to the relevant counterfactual outcome under that treatment strategy.

Hernán and Robins emphasize that consistency requires adequately specified, meaningful interventions; apparently simple treatment labels can conceal different versions of treatment that complicate the definition of the counterfactual outcome (Hernán & Robins, 2020).

For longitudinal treatment strategies, consistency and positivity likewise have sequential counterparts (Hernán & Robins, 2020).

Loss to Follow-Up Adds Another Weighting Problem

Treatment confounding and censoring are related but distinct problems.

Loss to follow-up can create selection bias when remaining observed depends on factors related to the outcome. In longitudinal causal inference, censoring itself can be treated as a time-varying process requiring appropriate adjustment.

Inverse-probability-of-censoring weighting (IPCW) assigns greater weight to participants who remain observed but resemble, in terms of measured history, participants who became censored.

Hernán and Robins distinguish treatment weights from censoring weights and describe causal analyses in which adjustment is needed for both confounding and selection bias from censoring (Hernán & Robins, 2020).

Fitzmaurice et al. describe a closely related weighting principle for longitudinal dropout. The probability of remaining in the study can be modeled sequentially from previous observed responses, covariates, and other predictors of dropout. Participants remaining observed are then weighted to correct the under-representation of response profiles more likely to disappear from follow-up (Fitzmaurice et al., 2011).

Treatment weights

Address confounding of treatment.

Censoring weights

Address selection from loss to follow-up.

When both processes threaten the intended causal analysis, both may need to be addressed.

A Practical Decision Framework

Before defaulting to standard regression, work through the causal ordering.

Step 1: Define the treatment strategy

Is treatment fixed once at baseline, or can treatment/exposure change repeatedly?

If it changes, specify the longitudinal treatment histories or strategies relevant to the research question.

Step 2: Identify time-varying causes of subsequent treatment and outcome

At each treatment occasion, ask which variables measured up to that time affect both the next treatment decision and the eventual outcome.

These are candidates for the sequential confounding set.

Step 3: Ask whether earlier treatment affects those later confounders

This is the key diagnostic.

If the required confounders are unaffected by previous treatment, ordinary adjustment may still be suitable, depending on the remaining causal and statistical assumptions.

If earlier treatment affects a later confounder that subsequently affects both treatment and outcome, treatment-confounder feedback is present.

Step 4: Do not confuse repeated-measures modeling with causal adjustment

A mixed model or GEE may appropriately account for correlated outcomes while leaving treatment-confounder feedback unresolved.

Choose the causal adjustment strategy separately from the model used to represent longitudinal outcome dependence.

Step 5: Consider a g-method

Hernán and Robins identify the g-formula, inverse probability weighting, and g-estimation as methods designed to handle time-varying treatments under the appropriate longitudinal identification conditions (Hernán & Robins, 2020).

If using IPW, specify treatment models based on treatment and covariate histories and use the resulting weights with an appropriate marginal structural model.

Step 6: Examine positivity and the weights

Determine whether each relevant treatment strategy is realistically represented across the covariate histories in the target population.

Estimated probabilities close to zero deserve particular attention because inverse weighting magnifies them.

Step 7: Address censoring separately

If loss to follow-up depends on measured treatment or outcome-related history, determine whether inverse-probability-of-censoring weighting or another appropriate missing-data strategy is needed.

Do not assume treatment weighting automatically solves informative dropout.

Step 8: Interpret the result as causal only under the assumptions

A weighted marginal structural model is not automatically causal because the software produced weights.

Interpretation still depends on the treatment strategy being well defined and on scientifically defensible exchangeability, positivity, consistency, measurement, censoring, and model-specification assumptions.

Common Mistakes

“I adjusted for every time-varying covariate, so confounding is controlled.”

Not necessarily. If some of those covariates were affected by earlier treatment, conventional conditioning can create the treatment-confounder feedback problem rather than solve it (Hernán & Robins, 2020; Lash et al., 2021).

“My mixed model handles repeated observations, so it handles time varying confounding.”

No. Accounting for within-subject correlation and removing causal confounding are different analytical tasks (Fitzmaurice et al., 2011; Hernán & Robins, 2020).

“Any time-varying covariate means I need an MSM.”

No. The specific warning sign is a covariate needed to control later confounding that is itself affected by previous treatment. Standard methods can remain adequate in simpler causal structures (Hernán & Robins, 2020; Lash et al., 2021).

“IPW eliminates the need for causal assumptions.”

It does not. IP weighting relies on the identification conditions needed to justify the weighted causal comparison, including exchangeability, positivity, and consistency (Hernán & Robins, 2020).

“Censoring weights and treatment weights do the same job.”

They do not. Treatment weighting targets confounding in treatment assignment; censoring weighting targets selection created by remaining observed. A longitudinal analysis can require both.

Bottom Line

The important dividing line is not cross-sectional regression versus longitudinal regression.

It is the causal ordering of treatment and confounders.

When treatment or exposure varies over time, ask whether previous treatment changes a later variable that both predicts subsequent treatment and predicts the outcome. If so, the analysis contains time varying confounding with treatment-confounder feedback.

In that setting, simply adjusting for the evolving confounder in an ordinary outcome regression can solve one part of the confounding problem while creating another. Hernán and Robins show why traditional adjustment methods can fail and why g-methods—including inverse probability weighting—are designed for these longitudinal causal structures (Hernán & Robins, 2020).

Inverse probability weighting approaches the problem by creating a weighted pseudo-population in which measured covariate history no longer drives treatment assignment in the same way. A marginal structural model can then describe causal contrasts between treatment strategies, provided the required exchangeability, positivity, consistency, and modeling conditions are defensible.

Repeated measurements alone do not make standard regression fail.

Treatment-confounder feedback is the warning sign.

FAQs

What is time varying confounding?

Time varying confounding occurs in longitudinal causal questions when variables that change over follow-up confound treatment or exposure decisions made at later times. The particularly difficult setting occurs when these later confounders are themselves affected by earlier treatment, creating treatment-confounder feedback (Hernán & Robins, 2020).

Why can standard regression fail with time varying confounding?

A later covariate may need adjustment because it confounds subsequent treatment, yet conditioning on it can be problematic because it is also a consequence of earlier treatment. Traditional adjustment can therefore remove later confounding while inducing bias for the earlier treatment history (Hernán & Robins, 2020).

Does every time varying exposure require a marginal structural model?

No. The need for specialized longitudinal causal methods depends on the causal structure. The critical issue is whether variables needed to control confounding of later exposure are themselves affected by previous exposure. Simpler structures may still permit conventional regression adjustment (Hernán & Robins, 2020; Lash et al., 2021).

What does inverse probability weighting do?

Inverse probability weighting gives greater weight to individuals whose observed treatment histories were relatively unlikely given their measured histories. Under the required assumptions, the resulting pseudo-population removes the measured dependence of treatment on confounder history needed for the causal comparison (Hernán & Robins, 2020).

What is a marginal structural model?

A marginal structural model specifies features such as the marginal mean of counterfactual outcomes under different treatment values or strategies. IP weighting can be used to estimate its causal parameters from observed data under the required identification and modeling conditions (Hernán & Robins, 2020).

What is the difference between stabilized and nonstabilized weights?

For time-varying treatment, both use probabilities conditional on measured treatment and covariate history in their denominators. Stabilized weights additionally use numerator probabilities based on treatment history. Hernán and Robins note that stabilized weights can improve statistical efficiency in nonsaturated weighted models (Hernán & Robins, 2020).

Is time varying confounding the same as correlation between repeated measurements?

No. Within-person correlation is a longitudinal statistical dependence problem. Time varying confounding is a causal problem concerning the relationship among treatment history, covariate history, and outcome. Methods designed for repeated-measures correlation do not automatically solve treatment-confounder feedback (Fitzmaurice et al., 2011; Hernán & Robins, 2020).

How does loss to follow-up fit into the analysis?

Loss to follow-up can create selection bias and may require inverse-probability-of-censoring weights based on the probability of remaining observed given measured history. These censoring weights solve a different problem from treatment weights, although both can be required in the same longitudinal causal analysis (Fitzmaurice et al., 2011; Hernán & Robins, 2020).

References

Fitzmaurice, G. M., Laird, N. M., & Ware, J. H. (2011). Applied longitudinal analysis (2nd ed.). Wiley.

Hernán, M. A., & Robins, J. M. (2020). Causal inference: What if. Chapman & Hall/CRC.

Lash, T. L., VanderWeele, T. J., Haneuse, S., & Rothman, K. J. (2021). Modern epidemiology (4th ed.). Wolters Kluwer.

Need help with a similar research question?

Share a short, non-confidential summary of your study and the decision you need to make.

Send an enquiry