# Pre-estimation analysis specification
Frozen before downloading participant-level data or estimating associations, 28 September 2026.

## Question and population
Describe the association of self-reported physical activity with prevalent diabetes in NHANES 2011–2018. Target: civilian noninstitutionalized US adults aged 20 or older, excluding known current pregnancy (RIDEXPRG=1). Retain unknown/not-applicable pregnancy status and report its limitations. This is a pooled historical cross-sectional association, not incidence, a causal effect, or a current national estimate. No earlier Case6 workspaces or outputs are inputs.

## Verified sources and runtime
Use official CDC DEMO, PAQ, DIQ, GHB, BMX and SMQ files for cycles G/H/I/J (2011/2013/2015/2017). Codebook pattern: https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2017/DataFiles/PAQ_J.htm; replace year and component as appropriate. Data use corresponding .xpt files. Retain URLs, access dates and hashes. CDC weighting guidance: https://wwwn.cdc.gov/nchs/nhanes/tutorials/weighting.aspx.
Verified native Notebook environment: case6-nhanes-gcc14-final2, R 4.4.3, survey 4.4.2, haven 2.5.5. Do not reinstall or modify application. Use English outputs.

## Coding
- Cohort: positive WTMEC2YR and valid masked design variables; construct the design on all examined participants before domain restrictions. Adult domain RIDAGEYR>=20, excluding RIDEXPRG=1.
- Recreational activity: vigorous PAQ650/PAQ655/PAD660 and moderate PAQ665/PAQ670/PAD675. Indicator 2 means zero, regardless of structurally skipped days/minutes; indicator 1 requires days 1–7 and minutes 10–1439. Refused, unknown and other invalid values are missing, never zero.
- Weekly moderate-equivalent minutes = moderate days*minutes + 2*vigorous days*minutes. Categories: none (reference, zero), 1–149, >=150. The questionnaire counts bouts of at least 10 minutes; do not label this a complete measure of current guideline adherence.
- Total activity sensitivity: add work (PAQ605/PAQ610/PAD615 and PAQ620/PAQ625/PAD630) and transport (PAQ635/PAQ640/PAD645, moderate equivalent). Require valid components. If the sum of unweighted actual reported minutes across available activity domains is >=10080 per week, invalidate both activity summaries; CDC already sets certain implausible reports missing. No post-result cut-point selection.
- Diabetes: positive if DIQ010=1, DIQ050=1, DIQ070=1, or observed LBXGH>=6.5%. Medication questions explicitly concern insulin or diabetic pills to lower blood sugar. Negative requires DIQ010 in {2,3}, observed HbA1c<6.5, no positive medication evidence and no explicit medication refusal/unknown (7/9). Structural medication skips alone do not create missingness for an otherwise negative participant. All other cases unknown. DIQ010 excludes diagnosis during pregnancy in adult women. This captures diabetes of any type, with single-test HbA1c evidence rather than clinical confirmation.
- Diagnosis-only sensitivity: DIQ010=1 versus {2,3}; other codes missing. It deliberately does not add medication or laboratory evidence.
- Age: natural cubic spline with fixed internal knots 35,50,65 and boundary knots 20,80; NHANES ages >=80 are top-coded. Sex: RIAGENDR factor. Race/ethnicity: RIDRETH3 six observed coded groups (1,2,3,4,6,7), treated as social/demographic covariates, not biological causes.
- Education: DMDEDUC2 groups 1/2 less than high school, 3 high school/GED, 4 some college/AA, 5 college graduate. Income: INDFMPIR 0–5 continuous linear term, acknowledging top-coding. Smoking: SMQ020=2 never; SMQ020=1 and SMQ040=3 former; SMQ020=1 and SMQ040 in {1,2} current; otherwise missing. BMI: BMXBMI>0, continuous natural spline with internal knots 25,30,35, boundaries 12,70 (linear tails). Cycle factor with 2011–2012 reference.
- Prespecify valid factor codes; report missing values and retained records by cycle. Do not impute covariates in this first investigation.

## Design and comparison models
Use weights WTMEC2YR/4, strata interaction(cycle,SDMVSTRA), PSU nested within strata. No fasting tests or fasting subsample weights. Check two PSUs per stratum and uniqueness across cycles. Set lonely-PSU behavior to fail; investigate rather than silently treating clusters as independent. Use subsetting of the full survey design for adult and complete-case domains.
Primary model comparisons use exactly the same complete-case adults with activity, primary diabetes, all adjustment variables and BMI:
U: ordinary unweighted logistic diabetes~activity.
W: survey-weighted logistic diabetes~activity.
D: W + age spline + sex + race/ethnicity + cycle.
S: D + education + income + smoking.
B: S + BMI spline.
Use quasibinomial survey GLMs to avoid irrelevant noninteger-weight warnings. Check convergence, rank, finite coefficients and cell counts; do not select models by significance. Race/ethnicity and other nuisance factor references use first coded level; explicit activity reference remains none. Report conditional odds ratios, not risk ratios.

## Standardization and uncertainty
For each model, replace activity with each category for all members of the common cohort, predict probabilities, and average. Use equally weighted standardization for U and survey-weighted standardization for W/D/S/B; explicitly identify this population difference when comparing U and W. Differences are category minus none; report percentage points.
Survey coefficient variance: Taylor linearization from survey::svyglm. Standardized prevalence/differences: stratified delete-one-PSU jackknife (survey::as.svrepdesign, type=JKn) constructed before domain subsetting; refit and recompute weighted standardization in every replicate, including variability in covariate distribution. Use replicate package scaling. Use two-sided 95% t intervals with model residual design degrees of freedom (design df minus model rank plus one). For standardized prevalence use logit-scale interval transformation; for prevalence differences use direct t intervals. Unweighted ORs use model-based covariance and large-sample normal intervals; standardized U estimates use delta-method coefficient covariance conditional on its empirical covariate distribution. This conditional U uncertainty is labeled.
Descriptive prevalence: survey::svyciprop with logit intervals and design df. Report unweighted denominators/events alongside weighted estimates. Report weight-only effective sample size as a diagnostic, not an actual design-adjusted sample size. Flag very small outcome cells (<10), wide intervals, or nonpositive residual df; withhold nonestimable results rather than changing the model to obtain significance. No multiplicity-adjusted confirmatory claims.

## Robustness and missingness
Compare full eligible crude results (available activity/outcome) with common-cohort crude results to separate sample-selection changes from adjustment. Report complete-case retention, variable missingness, and weighted age, sex and activity/diabetes profiles where observed among retained versus excluded eligible adults.
For diagnosis-only and total-activity sensitivity, refit W/S/B on the intersection of the primary common cohort and observed alternative outcome/exposure. In each sensitivity also refit the corresponding primary definition on that exact intersection so definition changes are not confused with participant changes. Report denominators and S standardized differences and ORs, with B and W in technical tables. No subgroup search or additional research extensions.

## Validation and delivery
Retain fresh official input files and codebooks; check unique SEQN, merges, coding and weight scale invariance. Verify standardized crude results against direct prevalence, replicate versus Taylor crude uncertainty approximately, and rerun the saved analysis script on retained inputs through native Notebook, comparing key results numerically.
Publish an English research brief, figures, CSV tables, source manifest, code, README and this specification as Artifacts. Explain reverse causation, residual confounding, self-report error, single HbA1c measurement, incomplete ascertainment, nonresponse/complete-case selection, historical target period, OR noncollapsibility and BMI ambiguity. Changes after freezing must be explicitly logged, not silently rewritten.
