PUBH-310 · Lesson 5 of 12 · 21 min

Confounding and how to control it

▶ Video coming soon A video version of this lesson is on the way.

Tomás brought a list to the analysis planning meeting: thirty-one variables available in the records, from age and sex to department, union membership, parking permit type and body mass index at hiring. “I suggest we adjust for all of them,” he said. “More adjustment is safer, isn’t it?” Priya shook her head. “Some of these could make the estimate worse.” Dr. Arkwright handed out sheets of blank paper. “Draw me the causal story first. Then we’ll know what to adjust for, and what to leave alone.”

PUBH-210 defined a confounder by three conditions and showed how stratification can reveal confounding. That rule-of-thumb definition works in simple cases but fails in others: it cannot tell a confounder from a collider, and it does not say which of several candidate variables must be adjusted for. This lesson introduces the modern approach: defining confounding through counterfactual comparisons, representing assumptions with directed acyclic graphs (DAGs), and choosing an adjustment set that removes confounding without creating new bias. It then surveys the methods for controlling confounding in design and analysis.

Confounding as non-exchangeability

Lesson 1 framed a causal effect as the comparison between what would happen to the same people under two exposures. Because we observe each person under only one, we compare exposed people with unexposed people and hope the unexposed show what would have happened to the exposed had they been unexposed. When that hope holds, the groups are exchangeable: swapping them would not change the result. Confounding is a lack of exchangeability: the unexposed group differs from the exposed group in its baseline risk of the outcome, for reasons other than the exposure.

Randomization creates exchangeability by design, on average. In observational studies, investigators aim for conditional exchangeability: within levels of measured variables, such as age and job type, exposed and unexposed people are assumed to be comparable. Whether that assumption holds cannot be proven from data; it depends on subject-matter knowledge about which variables cause both exposure and outcome. DAGs are a tool for making that knowledge explicit.

Reading a DAG

A DAG is a diagram in which variables are nodes and arrows represent direct causal effects. “Directed” means each arrow points one way; “acyclic” means no variable can cause itself through a loop of arrows (repeated measurements over time are drawn as separate nodes). The absence of an arrow is a strong assumption: it states that one variable has no direct effect on another.

A path is any sequence of arrows connecting two variables, regardless of direction. Paths between exposure and outcome are of two kinds. Causal paths follow the arrows forward from exposure to outcome, directly or through mediators. Backdoor paths begin with an arrow pointing into the exposure; they carry non-causal association and are the source of confounding. Three basic structures, shown in Figure 1, determine how association flows.

Three small diagrams. First, confounder, adjust: age has arrows to night shifts and to diabetes. Second, mediator, do not adjust for the total effect: night shifts has an arrow to sleep disruption, which has an arrow to diabetes. Third, collider, do not adjust: night shifts and diabetes each have an arrow into took part in survey. In each, a dashed arrow from night shifts to diabetes marks the effect being estimated.
Figure 1. Three structures: a confounder (a common cause), a mediator (on the causal path) and a collider (a common effect).
  • Fork (common cause): Night shifts ← Age → Diabetes. Age opens a backdoor path. Association flows through a fork unless we condition on (adjust for, stratify on, restrict to) the common cause. Adjusting for age blocks the path.
  • Chain (mediator): Night shifts → Sleep disruption → Diabetes. This is part of the causal effect. Adjusting for the mediator blocks part of the effect we want to estimate.
  • Collider (common effect): Night shifts → Took part in survey ← Diabetes. Two arrows collide at the node. A collider path is closed naturally: no association flows through it. Conditioning on the collider opens it, creating a spurious association between its causes. This is collider bias, and it underlies many forms of selection bias (lesson 8).

The backdoor criterion

A set of variables is sufficient to control confounding if it blocks every backdoor path from exposure to outcome and contains no descendants of the exposure (nothing caused by the exposure). This is the backdoor criterion, formalized by Judea Pearl. A minimal sufficient adjustment set is a sufficient set from which no variable can be removed. There may be several; investigators choose among them according to which variables are best measured. Free tools such as the web application DAGitty identify adjustment sets from a drawn DAG.

The Brannock DAG

The team drew the causal story over two sessions, arguing about every arrow. The simplified result is Figure 2.

A causal diagram. Age has arrows to rotating night shifts, to type 2 diabetes and to job type. Job type, nurse, aide or clerk, has arrows to rotating night shifts and to type 2 diabetes. Family history of diabetes has an arrow only to type 2 diabetes. Rotating night shifts has an arrow to weight gain, which has an arrow to type 2 diabetes. Both rotating night shifts and type 2 diabetes have arrows into sick leave record after diagnosis. A heading says the minimal adjustment set for the total effect is age and job type; weight gain is a mediator; the sick leave record is a collider; family history causes only the outcome and is optional but may add precision.
Figure 2. A simplified DAG for the Brannock study of rotating night shifts and type 2 diabetes.

Reading the DAG gives clear guidance. There are two backdoor paths: Night shifts ← Age → Diabetes, and Night shifts ← Job type → Diabetes (plus Night shifts ← Job type ← Age → Diabetes, which is blocked by either age or job type). Adjusting for age and job type blocks them all. Weight gain is a mediator: adjusting for it would estimate only the part of the effect not operating through weight, not the total effect the question asks about. The sick leave record after diagnosis is a collider and also a descendant of the outcome; adjusting for it would create bias. Family history affects only the outcome; it is not a confounder, but adjusting for it is harmless and can improve precision.

What about body mass index at hiring? Because it was measured before the schedule assignment, it cannot be a mediator of the current exposure. If higher body mass index influences who chooses nights (some staff believed night work suited people with health conditions) and affects diabetes risk, it is a confounder and should be added. But body mass index measured after time zero would be partly a consequence of night work and must not be adjusted for in estimating the total effect. This is why the timing of every covariate relative to time zero, recorded in the measurement plan, matters so much.

Why “adjust for everything” fails

Tomás’s proposal illustrates four ways that extra adjustment can harm:

  • Adjusting for a mediator (overadjustment) removes part of the effect being estimated, usually biasing toward the null.
  • Adjusting for a collider or a descendant of a collider opens a non-causal path and can create an association where none exists.
  • Adjusting for an instrument, a variable that affects exposure but has no other link to the outcome, such as the parking permit type tied to shift times, adds no confounding control, increases variance and can amplify any residual confounding.
  • M-bias: a pre-exposure variable can be a collider between two unmeasured causes, one of the exposure and one of the outcome. Adjusting for it opens a path. In practice, M-bias is usually small, and most methodologists advise adjusting for pre-exposure common causes even when M-structures are possible.

The general lesson is that confounders are selected using causal knowledge, not by screening variables for statistical significance or by stepwise regression. A useful default when the full causal structure is uncertain is the disjunctive cause criterion proposed by VanderWeele: adjust for each pre-exposure covariate that is a cause of the exposure, the outcome or both; exclude known instruments; and include proxies for unmeasured common causes.

The change-in-estimate approach and its limits

A traditional strategy adds a candidate variable to the analysis and keeps it if the effect estimate changes by more than a threshold, often 10 percent. This can usefully flag variables that matter, but it has two weaknesses. A collider or mediator will also change the estimate, so the rule cannot distinguish confounding from bias introduced by adjustment. And with odds ratios, the estimate can change on adjustment even without confounding, because the odds ratio is non-collapsible: the adjusted odds ratio can differ from the crude one when a variable affects the outcome strongly, even if it is unrelated to the exposure. Change-in-estimate should be used only among variables that the DAG already identifies as potential confounders.

Residual confounding

Adjustment removes confounding only to the extent that the confounder is measured accurately and finely enough. Confounding that remains after adjustment is residual confounding. Coarse categories are a common cause.

Worked problem

Residual confounding from a coarse confounder

In a fictional cohort of 3,000 people, an exposure has no effect on the outcome. Smoking has three levels: none (1,000 people, risk 0.02), light (1,000, risk 0.05) and heavy (1,000, risk 0.10). The exposure is more common among smokers: 20 percent of non-smokers, 40 percent of light smokers and 70 percent of heavy smokers are exposed. Calculate the crude risk ratio, the risk ratio after adjusting for smoking coded only as “any” versus “none,” and after adjusting for all three levels.

Show solution
  1. Exposed: 200 non-smokers (4 cases), 400 light (20 cases), 700 heavy (70 cases): 94 cases in 1,300, risk 0.072. Unexposed: 800 non-smokers (16), 600 light (30), 300 heavy (30): 76 in 1,700, risk 0.045. Crude RR = 0.072 ÷ 0.045 = 1.62.
  2. Binary coding, smokers: exposed 1,100 with 90 cases (0.082); unexposed 900 with 60 cases (0.067). RR = 1.23. Non-smokers: 0.02 versus 0.02, RR = 1.0.
  3. Three-level coding: within each level the risks are identical in exposed and unexposed (0.02, 0.05, 0.10), so every stratum RR is 1.0.

Answer: Crude RR 1.62; adjusting for smoking as a yes-or-no variable leaves an RR of 1.23 among smokers, because exposed smokers are mostly heavy smokers; only adjusting for the full intensity removes the confounding (RR 1.0). Coarse or error-prone measurement of a confounder leaves residual confounding.

The same problem arises with confounders measured with error, such as self-reported physical activity or diet, and with confounders not measured at all. Socioeconomic position is a frequent culprit, because it is multidimensional and hard to capture with one variable.

Methods of control: design and analysis

Table 1. Methods for controlling confounding.
MethodStageHow it worksMain limitation
RandomizationDesignChance assignment balances measured and unmeasured confounders on averageNot possible for many exposures
RestrictionDesignInclude only one level of a confounder (for example, non-smokers)Reduces sample and generalizability
MatchingDesignSelect comparison subjects similar on confoundersMatched factors cannot be studied; must be accounted for in analysis
Stratification and Mantel-HaenszelAnalysisEstimate within strata and pool (lesson 6)Few confounders at once before strata become sparse
StandardizationAnalysisApply stratum-specific rates to a common population (lesson 6)Same sparsity limits as stratification
Multivariable regressionAnalysisModel the outcome with exposure and confounders togetherDepends on correct model form
Propensity scoresAnalysisModel the probability of exposure given confounders; match, weight or stratify on itControls only measured confounders
Inverse probability weightingAnalysisWeight people to create a pseudo-population with no confounding; handles time-varying confoundingUnstable with extreme weights

All methods in the analysis rows control only for measured confounders. Their differences lie in how they use the data and what modelling assumptions they make. Propensity score methods, popular in pharmacoepidemiology, separate the design (balancing confounders between groups, which can be checked) from the outcome analysis, and make it easy to see when exposed and unexposed groups do not overlap. Inverse probability weighting and related “g-methods” developed by Robins are needed when a confounder is affected by earlier exposure and also affects later exposure, a situation called time-varying confounding, which standard regression cannot handle correctly. In the Brannock study, weight gain over time could be both a consequence of past night work and a reason to switch schedules, so a per-protocol analysis of continuous night work would require such methods.

When confounders are unmeasured

Several strategies address confounding by variables that were not measured:

  • Negative control outcomes: an outcome that the exposure cannot plausibly cause but that shares the same confounders. If night workers show an “effect” on, say, hip fractures from falls on ice, which shift work should not cause, the main result may be confounded too.
  • Negative control exposures: an exposure with the same confounders but no plausible effect.
  • Active comparators: comparing two treatments for the same indication, or two jobs with similar demands, reduces confounding by indication or by underlying health.
  • Instrumental variables: a variable that affects exposure, has no other path to the outcome and shares no causes with it. Mendelian randomization uses genetic variants as instruments, relying on the random allocation of genes at conception. Instruments must meet strong, untestable assumptions.
  • Sensitivity analysis: quantifying how strong an unmeasured confounder would need to be to explain the result away, such as with the E-value (lesson 8).

The Table 2 fallacy

Many papers present one regression model with the exposure and all confounders, then interpret every coefficient in the table as a causal effect. This is the Table 2 fallacy, named after the table where such models usually appear. The adjustment set chosen for the exposure is generally wrong for the other variables. In the Brannock model, the coefficient for age is adjusted for job type and night work, which are consequences of age; it is not the total effect of age on diabetes. Each causal question needs its own DAG and adjustment set.

Common mistakes

  • MistakeAdjust for every available variable to be safe.

    InsteadAdjusting for mediators, colliders or instruments can introduce or amplify bias; select confounders with causal reasoning.

  • MistakeSelect confounders by keeping variables with p-values below 0.05.

    InsteadStatistical significance does not indicate confounding; use a DAG or the disjunctive cause criterion.

  • MistakeAdjusting for smoking as yes or no removes confounding by smoking.

    InsteadCoarse or mismeasured confounders leave residual confounding.

  • MistakeCovariates measured after the exposure starts are fine to adjust for.

    InsteadPost-exposure covariates may be mediators or colliders; adjust for pre-exposure covariates when estimating total effects.

  • MistakeEvery coefficient in a multivariable model is a causal effect.

    InsteadOnly the exposure coefficient is adjusted appropriately; this is the Table 2 fallacy.

Summary and key terms

  • Confounding is non-exchangeability: the unexposed do not represent what would have happened to the exposed without exposure.
  • DAGs encode causal assumptions; forks transmit association unless blocked, chains carry causal effects, colliders block association unless conditioned on.
  • The backdoor criterion identifies sufficient adjustment sets: block all backdoor paths and avoid descendants of the exposure.
  • Do not adjust for mediators (for total effects), colliders or instruments.
  • Residual confounding remains when confounders are coarse, mismeasured or unmeasured.
  • Design methods (randomization, restriction, matching) and analytic methods (stratification, standardization, regression, propensity scores, weighting) control measured confounding; negative controls, instruments and sensitivity analyses address unmeasured confounding.
Exchangeability
The condition in which exposed and unexposed groups would have the same outcome risk under the same exposure.
Directed acyclic graph (DAG)
A diagram of causal assumptions with arrows between variables and no loops.
Backdoor path
A non-causal path between exposure and outcome that begins with an arrow into the exposure.
Collider
A variable caused by two others on a path; conditioning on it opens a spurious association.
Mediator
A variable on the causal path from exposure to outcome.
Residual confounding
Confounding that remains after adjustment because of coarse, mismeasured or omitted confounders.
Propensity score
The probability of exposure given measured confounders.
Negative control outcome
An outcome the exposure cannot cause but which shares its confounders, used to detect bias.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. In a DAG, coffee → heart disease, smoking → coffee and smoking → heart disease. Coffee → sleep quality → heart disease. What should be adjusted for to estimate the total effect of coffee?

    Show answer

    Smoking (a common cause on a backdoor path). Sleep quality is a mediator and should not be adjusted for when estimating the total effect.

  2. A study of a drug restricted to hospitalized patients finds the drug linked to lower mortality from an unrelated disease. Both the drug’s side effects and the disease lead to hospitalization. What structure could explain this?

    Show answer

    Hospitalization is a collider between the drug (through side effects) and the disease; restricting to hospitalized patients conditions on it and can create a spurious association.

  3. Why is a parking permit type tied to shift times a poor choice of adjustment variable?

    Show answer

    It is an instrument: it affects (or reflects) the exposure but has no separate path to diabetes. Adjusting for it controls no confounding, increases variance and can amplify residual confounding.

  4. Suggest a negative control outcome for a study of influenza vaccination and all-cause mortality in older adults.

    Show answer

    Mortality in the months before influenza season, or injury deaths. Vaccination should not reduce these; an apparent benefit would suggest healthy-user confounding.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz