Statistics Lab · step 06

Understand confounding.

Use temporal and causal knowledge to choose an adjustment set, then compare crude and adjusted estimates without overclaiming.

Outcome: a transparent adjustment rationale and an interpretation that separates association from causation.

Seven-step investigationNow: 06 · Understand confounding

Analysis checkpoint

Use the timeline to decide what adjustment means.

Work through these six prompts in order. Each one supplies what the next one needs.

1 · Before you start

Have a crude and an adjusted model for the same outcome, with baseline variables chosen before comparing the estimates.

Words used on this page

Confounder
a pre-exposure cause of, or defensible proxy for causes of, both exposure and outcome.
Mediator
a variable on the pathway through which an exposure may influence an outcome.
Collider
a common consequence of two variables; conditioning on it can create bias.
Confounding by indication
treatment is more likely in people already at higher clinical risk.
Residual confounding
confounding that remains because variables were unmeasured or measured imperfectly.
2 · Why this comes now

The reviewed and unreviewed groups were not created by randomisation. Comparing crude and adjusted estimates now shows how measured baseline differences alter the association and what uncertainty remains.

3 · Do this now
  1. Draw baseline causes before medication review and six-month outcomes after it.
  2. Classify each candidate variable as a confounder, mediator, collider or duplicate measure.
  3. Compare the medication-review estimate from the crude and pre-specified adjusted models.
Same step in Stata and SPSS

Run Section 06 in Stata or SPSS. Compare the same medication-review coefficient and confidence interval across models; do not choose adjustment variables because they change a p-value.

4 · Read this

Read the direction and size of the estimate change, not only whether either p-value crosses 0.05. Then ask which measured baseline differences explain that change and which unmeasured differences could remain.

5 · Ready to continue when

You can justify each included baseline variable, identify variables that should not be adjusted for automatically and state that residual confounding is still possible.

6 · Next step 07 · Complete the analysis Rerun the whole chain and turn it into a reproducible epidemiological account.

Causal structure

Confounding is not a software option.

A confounder is a pre-exposure common cause of the exposure and outcome, or a measured proxy that belongs in a defensible adjustment set. In this teaching cohort, baseline frailty increases the chance of receiving a medication review and the chance of later disability.

Baseline frailty → review

Selection into exposure

Frailer participants are more likely to receive a structured review.

Baseline frailty → outcome

Baseline risk

The same frailty measure predicts disability, quality of life, falls and admission.

Covariates should be selected before looking at which version gives the preferred result. A “10% change” rule or a univariable p-value is not a causal model.

Worked change

Crude and adjusted answer different questions.

Disability · crude

OR 1.04: the observed groups have almost identical unadjusted odds.

Disability · adjusted

OR 0.64 after accounting for the pre-specified baseline covariates.

Quality of life · crude

Mean difference −0.001: essentially no unadjusted difference.

Quality of life · adjusted

Mean difference +0.047 after separating review status from recorded baseline risk.

Representative output · same teaching data in all three routes

Crude versus adjusted disability model

Medication-review estimate       Odds ratio        95% CI
Crude                                1.04           0.70 to 1.54
Adjusted*                            0.64           0.41 to 1.01

* age, sex, living alone, deprivation, medication count,
  baseline frailty and baseline disability

What the output means

The crude model compares the observed exposure groups as they entered the cohort. The adjusted model compares them conditional on the recorded baseline variables. Movement from 1.04 to 0.64 is consistent with confounding by indication: participants at higher baseline risk were more likely to receive a review. The adjusted interval still includes 1, and unmeasured confounding may remain.

Write the interpretation like this

The crude odds ratio for six-month disability was 1.04 (95% CI 0.70 to 1.54). After adjustment for the pre-specified baseline covariates, the odds ratio was 0.64 (95% CI 0.41 to 1.01). The change was consistent with confounding by indication, although residual confounding cannot be excluded.
Stata

Store the crude and adjusted models, then compare the medication-review estimate rather than comparing p-values.

logistic disability_6m i.med_review
estimates store crude

logistic disability_6m i.med_review c.age_years i.sex ///
    i.lives_alone c.deprivation_score c.medication_count ///
    c.baseline_frailty i.baseline_disability
estimates store adjusted

estimates table crude adjusted, eform b(%8.2f) se(%8.2f)
Download the complete commented Stata do-file
IBM SPSS Statistics

Run the exposure-only model and the pre-specified adjusted model as separate blocks; compare Exp(B) and its interval.

LOGISTIC REGRESSION VARIABLES disability_6m
  /METHOD=ENTER med_review
  /PRINT=CI(95).

LOGISTIC REGRESSION VARIABLES disability_6m
  /METHOD=ENTER med_review age_years sex lives_alone
    deprivation_score medication_count baseline_frailty
    baseline_disability
  /CATEGORICAL=med_review sex lives_alone baseline_disability
  /PRINT=CI(95).
Download the complete commented SPSS syntax file
R and RStudio

Fit both models and extract the same coefficient on the odds-ratio scale.

crude <- glm(
  disability_6m ~ med_review,
  family = binomial,
  data = cohort
)

adjusted <- glm(
  disability_6m ~ med_review + age_years + factor(sex) +
    factor(lives_alone) + deprivation_score + medication_count +
    baseline_frailty + factor(baseline_disability),
  family = binomial,
  data = cohort
)

c(
  crude_OR = exp(coef(crude)["med_review"]),
  adjusted_OR = exp(coef(adjusted)["med_review"])
)
Download the complete commented R script

Adjustment changes an estimate under model assumptions; it does not repair unmeasured confounding, measurement error, selection bias or a poorly defined causal question.

What not to adjust for

Mediators and colliders need different handling.

RoleRelationshipDefault implication
ConfounderCommon cause of exposure and outcome.Often belongs in the adjustment set if measured well.
MediatorOn the causal path from exposure to outcome.Do not adjust if estimating the total effect.
ColliderCommon effect of two variables.Conditioning can create bias.
Precision variablePredicts outcome without causing exposure.May improve precision but is not a confounder.

DAGitty tutorials

Interactive explanations of confounders, mediators, colliders and adjustment sets.

Open DAGitty Learn

Covariate roles

A focused interactive guide to classifying variables in causal diagrams.

Open the tutorial