Week6 complex survey design

Week 6 — Complex survey design: the NHANES workflow, then the MASLD estimates

Duration: ~2.5 h (Tue 13 Oct, before the Thu 15 Oct lab). Deck: lectures/slides/Week6_survey_slides.qmd. Its MASLD numbers come from lectures/analysis/Week6_design_aware.R (written to Week6_design_aware.json) and from the M1 and paper result objects (examples/_results/). The code and output on its code slides come from lectures/analysis/Week6_code_outputs.R, which runs each block exactly as shown and records what R printed. The two pooling examples for cycles outside 2007–2018 (Slides 20 and 22, and appendix A13) cannot run on our data; a check runs them on a small made-up file and compares the weights they build with the slides’ formulas.

The design. Start with how NHANES actually draws its sample: strata first, then PSUs, segments, households and people. Then isolate what a weight does in a made-up town of 1,000, where the sample’s answer and the town’s can be checked by hand. Then the NHANES rules: which weight, how to pool cycles, design first and subset() second. Then MASLD as the audit: Weeks 4 and 5’s own estimates, redone with the design on the same rows.

Timing. The deck carries no timing marks; the minutes below are this plan’s. They add up to 128 minutes of content. With the 10-minute break after Slide 35 the total is 138 minutes, leaving 12 minutes of the 150-minute class for questions. If you are running behind at the foot of this file gives the cut order.

Slide numbers. Slide 1 here is the deck’s first content slide, “Why Week 6 matters”. The deck’s own counter also counts the title slide and the five section dividers, so on screen it runs ahead of this plan: by 1 for Slides 1–7, 2 for Slides 8–23, 3 for Slides 24–35, 4 for Slides 36–50 and 5 for Slides 51–56. The appendix is A1–A18 (screen 63–80).

Built on Weeks 4–5. Same rows (5,911), same pre-exposure adjustment set L (age, sex, race/ethnicity, smoking, sedentary time), same questions (Week 4’s obesity HR and Week 5’s waist-fat-by-obesity question). Week 4’s notes promised that Week 6 would redo its analyses with the survey weights; Slides 40–43 do. Week6_design_aware.R stops if its unweighted numbers differ from the ones Weeks 4 and 5 emitted.

Row-set discipline. Every quantitative slide names its rows.

What this week does NOT do.

Learning objectives

By the end, students can work through the deck’s five questions in order (Slide 7):

  1. Who? Name the population an estimate describes: the people sampled, or the population the survey represents.
  2. Which weight? Choose the weight of the smallest NHANES component that measured every variable, and pool cycles by what each supplied weight represents: ÷ 6 for 2007–2018, the NCHS four-year weight whenever 1999–2000 is included, and time fractions with the 3.2-year 2017–March 2020 file.
  3. How sampled? Declare the weight, strata (SDMVSTRA) and PSUs (SDMVPSU) with nest = TRUE on the whole file the weight belongs to.
  4. Which subgroup? Reach the analysis rows with subset(), explain a lonely PSU, and report the unweighted n beside every weighted estimate.
  5. Which model? Fit svymean(), svyglm() or svycoxph(), test on the design’s degrees of freedom, and read a weighted–unweighted gap as a question, not a diagnosis.

They can also say why survey weighting is neither confounding adjustment (Slides 13 and 41) nor inverse-probability-of-treatment weighting (Slide 27).

Continuity

Opening · 18 minutes

Slide 1 — Why Week 6 matters (3 min)

Slide 2 — NHANES: stratify first, then sample in stages (3 min)

Slide 3 — What are a stratum and a PSU? (3 min)

Slide 4 — What the public NHANES file gives you (2 min)

Slide 5 — Why sample this way? (2 min)

Slide 6 — One set of rows, two different mixes (3 min)

Slide 7 — The workflow for today (2 min)

Who? → Which weight? → How sampled? → Which subgroup? → Which model? Software comes last: svydesign() cannot choose the population or the weight.

Part 1 · What a survey weight does · 37 minutes

Slide 8 — A public-health town: younger and older adults (3 min)

Slide 9 — In R: the toy weight (2 min)

The table as a data frame. The weights add back to the town: 100 × 9 + 100 × 1 = 1,000.

Slide 10 — Hypertension prevalence: sample versus town (4 min)

Slide 11 — In R: build the town sample (2 min)

mean(s$htn) gives 0.275, the prevalence among the 200 sampled people.

Slide 12 — In R: let the weights reconstruct the town (2 min)

Slide 13 — Age can matter for two different reasons (2 min)

Slide 14 — Back to NHANES: the final weight is more than 1 / probability (2 min)

The final weight also carries a non-response adjustment and calibration to population control totals. NHANES supplies it; the analyst’s job is to choose the right one.

Slide 15 — Which NHANES weight? (3 min)

Slide 16 — MASLD: follow the measurement path (4 min) · do not drop

Slide 17 — Combining ordinary two-year cycles (3 min)

Slide 18 — In R: / 6 changes totals, not the model coefficient (2 min)

Slide 19 — First special case: analyses that include 1999–2000 (2 min)

Slide 20 — In R: pooling 1999–2004 (1 min)

SDDSRVYR 1 and 2 are 1999–2000 and 2001–2002 (four-year weight × 2/3); 3 is 2003–2004 (two-year weight × 1/3). This code is checked on a made-up file; our data start in 2007.

Slide 21 — Second special case: 2017–March 2020 is a 3.2-year file (2 min)

2015–2016 (2 years) + 2017–March 2020 (3.2 years) = 5.2 years, so the weights are scaled by 2/5.2 and 3.2/5.2. Each component gets its share of the combined period.

Slide 22 — COVID-era example in code (1 min)

Slide 23 — Three pooling situations to remember (2 min)

Ordinary two-year cycles from 2001–2002 on: divide by the number of cycles. Anything with 1999–2000: start from the NCHS four-year weight. 2017–March 2020: time fractions. First ask what period and population each supplied weight already represents.

Part 2 · Weights, strata, PSUs, and subpopulations · 25 minutes

Slide 24 — Three design ingredients, three jobs (2 min)

The weight changes the estimate and its uncertainty. PSUs (who was sampled together) and strata (how the clusters were organised) change the uncertainty only.

Slide 25 — Why strata and PSUs matter (2 min)

Slide 26 — Design-based and model-based inference: the useful distinction (2 min)

Ordinary models treat the rows as the analysis data; survey models also use how the rows were sampled. This is not a claim that every unweighted coefficient is meaningless (Slide 46).

Slide 27 — Survey weights are not treatment/IP weights (1 min)

Survey weights represent the target population. IP weights balance an exposure comparison. Frequency weights count observations. Today is about survey weights.

Slide 28 — Build the survey design before defining the analysis subgroup (2 min)

Slide 29 — A domain is just the subgroup you want to analyse (1 min)

Adults with MASLD, women, Group I, adults aged 60+, complete cases for a model: NHANES sampled none of these as such. A domain analysis keeps the original design.

Slide 30 — Wrong and right ways to analyse a subgroup (3 min) · do not drop

Slide 31 — A small domain shows why the order matters (3 min)

Slide 32 — Complete cases are another domain - but that does not fix missing-data bias (2 min)

Slide 33 — A weighted estimate can still be based on little information (2 min)

A subgroup can represent millions and still rest on a few respondents. Show the unweighted n, the design effect, the design degrees of freedom and the interval width.

Slide 34 — Design effect and effective sample size (3 min)

Slide 35 — Table 1 for a complex survey (2 min)

BREAK (10 min), after Slide 35

Part 3 · Survey regression in the MASLD example · 40 minutes

Slide 36 — Fit the model on the design object (2 min)

Week 5’s model (obesity × waist fat, adjusted for L) with svycoxph() on des: the 5,911 rows reached by subset() from the fasting-subsample design. The design object, not the weight column alone, carries the inference.

Slide 37 — Tests use the survey design too (3 min)

Slide 38 — Weighting changes the real MASLD population mix only modestly (2 min)

Slide 39 — What can we say about the published Cox analysis? (4 min) · do not drop

Slide 40 — Start with one comparison (2 min)

Slide 41 — Adjustment and survey design are different choices (4 min) · do not drop

Slide 42 — Week 5’s effect-modification result, redone with the survey design (4 min) · do not drop

Slide 43 — In R: the Week 5 interaction model, survey-aware (2 min)

waist_hr(fit, 0) and waist_hr(fit, 1) read waist fat’s HR among the not obese and the obese from one product-term model, ordinary and survey-aware.

Slide 44 — The correct weight is chosen by the measurement process (3 min)

Slide 45 — In R: sensitivity to the exam weight (2 min)

The same model on a design built from the exam sample, reached with subset(). This is the sensitivity run P4 asks for.

Slide 46 — Why can weighted and unweighted regression differ? (2 min)

Slide 47 — Why weighting can change an overall RR (4 min) · do not drop

Slide 48 — In R: build the high-sodium example (1 min)

Half of each age group exposed; incident hypertension 10% → 20% (younger) and 20% → 60% (older).

Slide 49 — In R: sample RR versus town RR (2 min)

A log-link Poisson glm() on the sample gives 2.67; svyglm() with a quasi-Poisson log link on the weighted design gives 2.18. The rows did not change; the population averaged over did.

Slide 50 — What survey design cannot fix (3 min)

Part 4 · Reporting and synthesis · 8 minutes

Slide 51 — Report the same decisions you made (3 min)

Population, weight (name, reason, pooling), strata and PSUs with the variance method, domain and complete-case restrictions with the unweighted n, and the survey estimator with its design degrees of freedom. Unweighted n + weighted % is the usual descriptive pairing.

Slide 52 — The algorithm to take into your own paper (2 min)

The seven steps and the five checks. This is P4’s workflow.

Slide 53 — Key takeaways (3 min)

Slides 54–56 — Sources and references (0 min)

Point students to the EpiMethods pages and the NCHS tutorials on Slide 54; do not present them.

Appendix (uncounted, A1–A18)

Thursday — L5 (EpiMethods surveydataE) · for the TA and the instructor, not in the deck

Say this out loud, twice: L5 is not MASLD. The numbers below were re-run on the lab’s own files on 2026-10-07. They are not emitted, so re-check them if the exercise changes.

  1. What it is. Flegal et al. 2016 (JAMA), NHANES 2013–14 only: It rehearses design → subset() → svyglm(). The exercise fits no unweighted model; to show the sample-vs-population contrast, add one glm() on the same men.
  2. The weight. The exercise uses WTINT2YR, the only weight in its file, for an exam-measured outcome (BMI).
  3. Intervals. One OR can come with three intervals:
  4. 2(c), AIC backward selection. step() on svyglm() uses a design-based AIC, so the mechanics are survey-correct. Choosing the adjustment set by AIC is what Week 4 warned against. Flegal’s Table 3 is descriptive, so present this as a prediction-style choice, not confounder selection.
  5. 2(d), the age × smoking interaction. The solution’s anova(fit.male, fit2)$p is a Rao–Scott test of a 4-df interaction, and it prints p = 0.40.
  6. Housekeeping.

If you are running behind

Cut in this order. Each idea is said elsewhere.

  1. Slide 20, the 1999–2004 code: Slide 19’s formulas carry it (1 min). Keep Slide 22: it holds the three-component example and the comparability warning.
  2. Slide 31, the small-domain demo: one sentence on Slide 30 (3 min).
  3. Slides 48–49, the RR code: Slide 47’s table carries the point (3 min).
  4. Slides 44–45, the exam-weight sensitivity: one sentence, and P4 asks for it (5 min).
  5. Slide 26: one sentence on Slide 24 (2 min).

Never cut Slides 16, 30, 39, 41, 42 or 47.

Reading map — each segment and where students can review it

Segment EpiMethods Reading
The NHANES design (Slides 1–7, 24–27) Concepts (D): The Three Pillars Lumley 2010, ch. 1–2; NCHS Sample Design tutorial
What a weight does (Slides 8–14, 34) DEFF Kish 1992
Which weight, pooling (Slides 15–23) Selecting the Correct Weight; Combining Survey Cycles Johnson et al. 2013; NCHS 2021 (Series 2, No. 190)
Domains and subsets (Slides 28–33) Analyzing Subpopulations; Properly subsetting a design object Lumley 2010
Models and tests (Slides 36–39) Hypothesis Testing in the Design-Based Framework Binder 1992; Lumley & Scott 2017
Weighted vs unweighted (Slides 40–50) A Word of Caution About “Weights” DuMouchel & Duncan 1983; Solon et al. 2015
Reporting (Slides 35, 51–53) PRICSSA; reliability standards Seidenberg et al. 2023

References