Metric cards smoking-cessation-ipw

Weight gain from quitting smoking

Inverse-probability-weighted difference in 10-year weight change, quitters vs non-quitters (NHEFS)

1 The gist · for everyone

If every smoker in this study had quit, how much more weight would they have gained over about ten years than if none had quit?

+3.44
kg more weight gain from quitting, averaged over everyone in the study
Plausible range +2.41 to +4.47

We followed 1,566 adult smokers from a health check in 1971–75 to a second visit in 1982. We compare weight change in people who quit with people who did not, after so the two groups match on nine traits.

Without the reweighting the gap is 2.54 kg. Non-quitters gained about 2 kg on their own.

Picture two groups of 100 smokers who are alike in every measured way. Over about ten years the group that quits gains about 340 kg more in total than the group that keeps smoking: roughly 3.4 kg each.

What kind of claim: Points toward a cause, with assumptions. The design removes some alternative explanations, not all. Read it as a cause only if its assumptions hold.
024Quitters, reweighted5.22 · n=403Non-quitters, reweighted1.78 · n=1,163Difference vs Non-quitters, reweighted: +3.44
Compare the two reweighted groups. Because both are made to resemble the whole study, the gap estimates what quitting would do on average across all of these smokers.

Safe to say

"Under the study's assumptions, quitting smoking added about 3.4 kg (2.4 to 4.5) of weight gain over roughly ten years, on average across these smokers."

Not this

"Quitters gained 3.4 kg," or "every smoker who quits will gain 3.4 kg."

Before you repeat it

This is only causal if the nine traits capture everything that made people both quit and gain weight. The study also kept only people alive and measured in 1982, which the authors flag as a possible source of bias they chose not to fix.

2 How it's built · for the curious

How the number is made

Follow one person: Ruth

Ruth is a 45-year-old smoker at her 1973 health check, weighing 68 kg. Women like her, with her smoking history, quit less often than average.

Time to quit · months 1–731982 visit · months 73–144First health check (day 0)123month 73month 144
  1. 1day 0 First health check: smokes, weighs 68 kg
  2. 2day 1460 Quits smoking (around 1977)
  3. 3day 3255 1982 visit: weighs 75 kg, a 7 kg gain counts

Result: Ruth adds 7 kg to the quitters' average. Because people like her rarely quit, she counts for more than one person in the quitter group. Had she missed the 1982 weigh-in, she would not count at all.

Now the general rule, one step at a time. Each step has the plain version, with the exact version one click away.

  1. Step 1 · Who is counted

    Start with people, then apply each rule

    One adult who smoked at the first health check.

    Exactly

    One row per seqn in nhefs.csv (1,629 rows).

    S3S1
    All people
    Keep if Adults aged 25–74 who smoked at the first health check and had the basic facts recorded (sex, age, race, weight, height, education, alcohol use, smoking intensity).1,629 remain
    Keep if Had their weight measured at the 1982 visit.1,566 remain
    Counted in the denominator
  2. Step 2 · When the clock starts

    Time zero: first health check

    Each person's first health check, held some time between 1971 and 1975.

    • Time to quit: Any time between the first health check and the 1982 visit. Quitting counts if the person reported having quit by 1982. (from 1 to 73 months (up to, not including, 73))
    • 1982 visit: The second visit in 1982, roughly 7 to 11 years after the first, depending on when that was. (from 73 to 144 months (up to, not including, 144))
    Exactly

    Baseline visit 1971–75 (§12.1 margin note). Visit dates are not in nhefs.csv.

    S1
    Time to quit · months 1–731982 visit · months 73–144First health check (day 0)month 73month 144
  3. Step 3 · What counts

    Weight change

    Body weight at the 1982 visit minus body weight at the first health check, in kilograms.

    Also measured the same way:

    • Quit smoking: Reported in 1982 having quit smoking.
    Exactly

    wt82_71 = wt82 − wt71 (kg); matches the difference of the two columns to 1e-14.

    S1S3
    Time to quit · months 1–731982 visit · months 73–144First health check (day 0)123month 73month 144
  4. Step 4 · Combine

    Average across people

    Average weight change in each group, with each person counted according to their weight.

    Exactly

    Weighted least squares of wt82_71 on qsmk; the intercept is the weighted mean for non-quitters and intercept + slope the weighted mean for quitters.

    S2S4
    weighted sum of weight change in the group
    sum of the weights in the group403
    = 5.22Quitters, reweighted
  5. Step 5 · Compare

    Compare with a matched group

    Compare the two reweighted groups. Because both are made to resemble the whole study, the gap estimates what quitting would do on average across all of these smokers.

    mean if all quit − mean if none quit

    With the real numbers: 5.221 − 1.78 = 3.441

    Whose effect? Average effect if everyone did it.

    Exactly

    θ₁ in E[Y | A] = θ₀ + θ₁A fitted to the pseudo-population (§12.2–12.3).

    S1S2
    024Quitters, reweighted5.22 · n=403Non-quitters, reweighted1.78 · n=1,163Difference vs Non-quitters, reweighted: +3.44
  6. Step 6 · Make it fair

    Reweight the comparison group

    People who were more likely to quit, given their traits, count for less; people unlikely to quit who did quit count for more. This balances the nine traits across the two groups.

    Exactly

    Logistic model for qsmk on the nine confounders, with squared terms for age, intensity, duration and weight, no interactions (Program 12.3, lines 93–97). Numerator: intercept-only logistic model (403/1566).

    S1S2S4

    Made similar on:

    • sex
    • race
    • age (linear and squared)
    • education (5 levels)
    • cigarettes per day (linear and squared)
    • years smoking (linear and squared)
    • exercise (3 levels)
    • how active day to day (3 levels)
    • baseline weight (linear and squared)
    024Quitters, reweighted5.22 · n=403Non-quitters, reweighted1.78 · n=1,163Difference vs Non-quitters, reweighted: +3.44
    Stabilized weights range 0.33 to 4.30 with mean 1.00 (book: 0.33 to 4.30, mean 1.00). Nonstabilized weights range 1.05 to 16.7 with mean 2.00. Program 12.2 tabulates one stratum (white women, by age) as a positivity check; the book recommends checking that stabilized weights average 1.
  7. Step 7 · How sure

    Show the range of plausible values

    The range 2.4 to 4.5 kg uses a standard formula that allows for the weighting. The authors describe it as slightly wider than necessary.

    Not covered by this range: Treats the propensity model as correct and the weights as known. It does not cover unmeasured confounding, the selection of people who survived to 1982, or the 63 people with no 1982 weight.

    Exactly

    geeglm(wt82_71 ~ qsmk, weights = sw, id = seqn, corstr = "independence"); β ± 1.96 SE. Reproduced with weighted least squares and HC0 standard errors: SE 0.525.

    S1S2S4
    0.0+1.0+2.0+3.0+4.0+5.0no difference
    Each dot is one of 20 equally likely values, given sampling noise alone (normal approximation to the interval).

3 Keep in mind · before you act on it

What could make this misleading

Completeness not stated. The card does not state when the data were complete, so we cannot confirm every window was fully observed.

Caveats

↑ May make the number look bigger than it really is↓ May make the number look smaller than it really is± The true uncertainty is larger than shown↕ Could push the number either way◎ Limits what the number can be used to conclude
↕

Only as good as the nine traits

removes differences in the nine measured traits. If something else, such as health worries, made people both quit and gain weight, it is still mixed into the number.

Could push the number either way · high importance S1

↕

Survivors only

Only people who lived to 1982 and came back could report quitting. If quitting affects survival, the groups are selected after the fact. The authors flag this and leave it unfixed.

Could push the number either way · medium importance S1

◎

Quitting happened at different times

Someone who quit in 1972 and someone who quit just before 1982 both count as quitters. The number averages over very different amounts of time without smoking.

Limits what the number can be used to conclude · medium importance S1

◎

The interval is wider than it needs to be

The robust formula behind 2.4 to 4.5 kg covers the true value more than 95% of the time, according to the authors. It still assumes the model for quitting is right.

Limits what the number can be used to conclude · low importance S1

Common misreadings

Tempting, but wrongAccurate
Quitters gained 3.4 kg.Quitters gained about 4.5 kg on average. 3.4 kg is the extra gain attributed to quitting after balancing the groups.
This is the effect for people who actually quit.It is the average effect if everyone in the study had quit, compared with nobody quitting (the ), not just the effect among quitters.
The raw gap of 2.5 kg is the effect of quitting.The raw gap mixes in age and smoking history differences. Reweighting moves it to 3.4 kg.

Same question, other reasonable choices

Each row reruns the analysis with one choice changed. If the rows disagree a lot, the headline depends on that choice.

0.0+2.0+4.0No adjustment (raw difference)Stabilized weights (headline)Nonstabilized weightsAlso weighting for missing 1982 weights
  • No adjustment (raw difference): Program 12.1: quitters 4.53 kg, non-quitters 1.98 kg.
  • Nonstabilized weights: Program 12.2; same estimate here.
  • Also weighting for missing 1982 weights: Program 12.7; book: 3.5 (2.5, 4.5).

Judgment calls

Which traits to balance

Chose: Nine traits measured at the first check, with squared terms for the continuous ones.

Could have chosen: More traits, interactions, or flexible models.

Why: A standard, transparent model for a teaching example.

What it changes: If an important cause of both quitting and weight gain is missing, the estimate is biased by an unknown amount.

Stabilized or plain weights

Chose: Stabilized.

Could have chosen: Plain inverse-probability weights.

Why: Usually narrower intervals.

What it changes: None here; both give 3.44 (2.41, 4.47).

People with no 1982 weight

Chose: Left out of the headline.

Could have chosen: Add weights for being measured (Program 12.7).

Why: Simpler first analysis; the book adds them in §12.6.

What it changes: 3.44 becomes 3.50.

4 Reproduce it · for specialists

The exact specification

Estimand

PopulationNHEFS participants aged 25–74 who smoked at the 1971–75 baseline visit, met the book's completeness restrictions, and had weight measured at the 1982 follow-up.
Exposure / contrastReported having quit smoking by the 1982 follow-up (qsmk = 1) vs not.
Time zeroBaseline visit, 1971–75.
VariableWeight at follow-up minus weight at baseline, kg (wt82_71).
Intercurrent eventsDeath or loss to follow-up before 1982 excludes the person from treatment classification (Fine Point 12.1); 63 eligible people lack a 1982 weight and are excluded from the headline.
Summary measureDifference in IP-weighted means, E[Y^{a=1}] − E[Y^{a=0}], kg; robust 95% interval.
TargetATE: Average effect if everyone did it

Where the description and the code disagree

Who is in the study

Described

Book margin note: restricted to people with known sex, age, race, weight, height, education, alcohol use and smoking intensity, who answered the medical history questionnaire.

Implemented

No code applies these rules. The downloadable nhefs.csv already contains only the 1,629 eligible people; the code's only restriction is a non-missing 1982 weight.

Impact: The eligibility rules cannot be checked or varied from the distributed files.

S1S2S3

Treatment model in the censoring analysis

Described

§12.6 says the model for being measured in 1982 was fit to all 1,629 people. It does not say the model for quitting was refit.

Implemented

Program 12.7 refits the quitting model on all 1,629 people (data = nhefs), not the 1,566 used for the headline.

Impact: Small. The censoring-weighted estimate is 3.50 vs 3.44.

S1S2

Input file

Described

The book's site provides nhefs.csv, NHEFS.xls and nhefs.dta.

Implemented

chapter12.R reads "XXXX/nhefs.xls" with readxl; other chapters point to a contributor's local Windows path.

Impact: None for the numbers; reproducers must edit the path.

S2S5

Year labels

Described

Baseline visits ran 1971–75 (§12.1).

Implemented

Columns are named wt71 and wt82_71, and chapter15.R labels groups "Quit Smoking 1971-1982".

Impact: Cosmetic, but readers of the code may assume a fixed 11-year gap.

S1S3S5

Rules as implemented

StageExact ruleSource
Eligibility 1
1,629 remain
Margin note to §12.1. Applied before distribution: nhefs.csv already holds only these 1,629 people, and no code restricts on these fields.S1S3
Eligibility 2
1,566 remain
nhefs.nmv <- nhefs[which(!is.na(nhefs$wt82)),] (chapter12.R line 12). Drops 63 people.S2S1
Time zeroBaseline visit 1971–75 (§12.1 margin note). Visit dates are not in nhefs.csv.S1
Time to quit
[1, 73) months
qsmk = 1 if the person reported in 1982 having quit (§12.1). The quit date is not used; the authors note it is really a time-varying treatment they ignore (Fine Point 12.1). The window shown is the shortest possible gap (1975 → 1982).S1
1982 visit
[73, 144) months
Follow-up visit in 1982 (§12.1); per-person gap between 73 and 143 months, not recorded in the file.S1S3
Weight change
value
wt82_71 = wt82 − wt71 (kg); matches the difference of the two columns to 1e-14.S1S3
Quit smoking
indicator
qsmk (0/1); 403 of 1,566 = 1.S1S3
AggregateWeighted least squares of wt82_71 on qsmk; the intercept is the weighted mean for non-quitters and intercept + slope the weighted mean for quitters.S2S4
Comparisonθ₁ in E[Y | A] = θ₀ + θ₁A fitted to the pseudo-population (§12.2–12.3).S1S2
AdjustmentLogistic model for qsmk on the nine confounders, with squared terms for age, intensity, duration and weight, no interactions (Program 12.3, lines 93–97). Numerator: intercept-only logistic model (403/1566).
Balances on: sex, race, age (linear and squared), education (5 levels), cigarettes per day (linear and squared), years smoking (linear and squared), exercise (3 levels), how active day to day (3 levels), baseline weight (linear and squared)
Diagnostics: Stabilized weights range 0.33 to 4.30 with mean 1.00 (book: 0.33 to 4.30, mean 1.00). Nonstabilized weights range 1.05 to 16.7 with mean 2.00. Program 12.2 tabulates one stratum (white women, by age) as a positivity check; the book recommends checking that stabilized weights average 1.
S1S2S4
Uncertaintygeeglm(wt82_71 ~ qsmk, weights = sw, id = seqn, corstr = "independence"); β ± 1.96 SE. Reproduced with weighted least squares and HC0 standard errors: SE 0.525.S1S2S4

Numbers per group

GroupDefinitionValuen
Quitters, reweightedqsmk = 1, stabilized weights Pr[A=1] / Pr[A=1 | L].5.221403
Non-quitters, reweightedqsmk = 0, stabilized weights (1 − Pr[A=1]) / (1 − Pr[A=1 | L]).1.781,163

Check: 5.221 − 1.78 = 3.441 (headline 3.44).

Parameters

NameValueMeaning
weightsstabilizedPr[A]/Pr[A|L] for quitters, (1−Pr[A])/(1−Pr[A|L]) otherwise
confounders9sex, race, age, education, intensity, duration, exercise, activity, weight
variancerobustGEE independence working correlation (R), HC0 (Python)

Data lineage

  1. nhefs.csv

    One row per eligible person; baseline traits, qsmk, wt71, wt82

    Grain: person

  2. chapter12.R

    Authors' code for Programs 12.1–12.7

    Grain: person → two weighted means

  3. examples/nhefs-ipw/analysis.py

    Python reproduction of Programs 12.1–12.3 and 12.7

    Grain: person → estimates

Code that defines it

Stabilized weights and the weighted model (authors' R, Program 12.3)examples/nhefs-ipw/data/chapter12.R:9-16, 51-76, 92-122, 231-292
pd.qsmk <- predict(denom.fit, type = "response")
numer.fit <- glm(qsmk~1, family = binomial(), data = nhefs.nmv)
pn.qsmk <- predict(numer.fit, type = "response")
nhefs.nmv$sw <- ifelse(nhefs.nmv$qsmk == 0, ((1-pn.qsmk)/(1-pd.qsmk)),
                    (pn.qsmk/pd.qsmk))
msm.sw <- geeglm(wt82_71 ~ qsmk, data=nhefs.nmv, weights=sw, id=seqn,
                corstr="independence")
The same estimate in Pythonexamples/nhefs-ipw/analysis.py:22-77
sw = np.where(unc.qsmk == 1, pn / p, (1 - pn) / (1 - p))
fit = smf.wls("wt82_71 ~ qsmk", df, weights=weights).fit(cov_type="HC0")

Rebuild it

Receipts:

  • 2026-10-07: stabilized IPW 3.441 (2.411, 4.470); book 3.4 (2.4, 4.5). Weights 0.331–4.298, mean 0.999.
  • 2026-10-07: unadjusted 2.541 (1.656, 3.425), book 2.5 (1.7, 3.4); Program 12.7 3.496 (2.466, 4.527), book 3.5 (2.5, 4.5).

Tests: Reproduced figures are compared with the book's text by hand; see the receipts.

Sources

  1. S1 examples/nhefs-ipw/data/hernanrobins_WhatIf_19aug26.pdf · Hernán & Robins, Causal Inference: What If, chapter 12 (§12.1–12.3, 12.6, Fine Point 12.1)
  2. S2 examples/nhefs-ipw/data/chapter12.R lines 9-16, 51-76, 92-122, 231-292
  3. S3 examples/nhefs-ipw/data/nhefs.csv · 1,629 rows; downloaded from miguelhernan.org/whatifbook
  4. S4 examples/nhefs-ipw/analysis.py lines 22-77 · Outputs in examples/nhefs-ipw/results/
  5. S5 examples/nhefs-ipw/data/chapter15.R lines 11, 82-83

Change log

  • Book version used for the cited text and figures.
  • Metric card written from nhefs.csv and chapter12.R; four discrepancies recorded.
Card quality checks: 0 errors · 1 warnings
  • info recompute estimate reproduced from cells: 5.221 − 1.78 = 3.441
  • warn maturity The card does not state when the data were complete, so we cannot confirm every window was fully observed.

Check yourself

Could you explain it to a colleague?

DetailThe headline is 3.4 kg. Which statement is right?
Big pictureWhat would make this number wrong as a causal effect?
Apply itA participant quit in 1980 but missed the 1982 weigh-in. Is she in the headline?

Explain it back

Write one or two sentences as if telling a colleague. Then compare with the checklist.

Glossary

95% range (95% interval, confidence interval)
The values that fit the data well, given random noise and the model. It does not cover traits nobody measured.
average treatment effect (ATE)
The average difference if everyone had quit compared with if nobody had quit.
inverse-probability weighting (IP weighting, IPW, reweighting, reweighted)
Counting each person more or less so that the groups being compared look alike on measured traits. People whose choice was unusual for someone like them count more.
robust variance (sandwich)
A way of computing the range that stays valid when people are counted with different weights.
stabilized weights
A version of the weights scaled to average about 1, which usually gives a tighter range.