Package: nhanesR 0.1.7

nhanesR: Download, Parse, and Analyze NHANES Data with Mortality Linkage

Provides tools for downloading and organizing National Health and Nutrition Examination Survey (NHANES) public-use data files and the National Center for Health Statistics (NCHS) Public-Use Linked Mortality Files (LMF). Supports structured local caching, codebook access, survey-aware merging, and preparation of survival analysis datasets using NHANES-National Death Index (NDI) linked mortality data (follow-up through December 31, 2019). NHANES methodology is described at <https://wwwn.cdc.gov/nchs/nhanes/Default.aspx>.

Authors:David Winsemius [aut, cre]

nhanesR_0.1.7.tar.gz
nhanesR_0.1.7.zip(r-4.7-any)nhanesR_0.1.7.zip(r-4.6-any)nhanesR_0.1.7.zip(r-4.5-any)
nhanesR_0.1.7.tgz(r-4.6-any)nhanesR_0.1.7.tgz(r-4.5-any)
nhanesR_0.1.7.tar.gz(r-4.7-any)nhanesR_0.1.7.tar.gz(r-4.6-any)
nhanesR_0.1.7.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
nhanesR/json (API)

# Install 'nhanesR' in R:
install.packages('nhanesR', repos = c('https://dwinsemius.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/dwinsemius/nhanesr/issues

Pkgdown/docs site:https://dwinsemius.github.io

On CRAN:

Conda:

6.57 score 3 stars 35 scripts 362 downloads 34 exports 31 dependencies

Last updated from:013da89ccc. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK142
source / vignettesOK204
linux-releaseOK134
macos-releaseOK101
macos-oldrelOK103
windows-develOK76
windows-releaseOK102
windows-oldrelOK81
wasm-releaseOK110

Exports:mortality_tabulationNH_describeNH_labelnhanes_cache_dirnhanes_cyclesnhanes_downloadnhanes_download_analytenhanes_followup_summarynhanes_harmonizenhanes_lmf_cyclesnhanes_manifestnhanes_mergenhanes_mortality_downloadnhanes_mortality_linknhanes_mortality_parsenhanes_search_variablesnhanes_stacknhanes_survival_prepnhanes_ucod_labelsnhanes_variable_mapnhanes3_downloadnhanes3_filesnhanes3_layoutnhanes3_readnhis_data_yearsnhis_downloadnhis_lmf_yearsnhis_mortality_downloadnhis_mortality_linknhis_mortality_parsesvycph_fusesvycph_set_basehaztabulation_gridweighted_basehaz

Dependencies:askpassbitbit64clicliprcpp11crayoncurlforcatsgluehavenhmshttr2lifecyclemagrittropensslpillarpkgconfigprettyunitsprogressR6readrrlangsystibbletidyselecttzdbutf8vctrsvroomwithr

NHANES III (1988-1994): Fixed-Width Files, Cotinine, and Mortality
Overview | 1. Download the files | 2. Read column positions from the SAS program | 3. Read only the columns you need | The same steps with the package functions | 4. Missing-value codes | 5. Look up variables in the codebook | 6. Smoking status, checked against cotinine | 7. Link mortality | 8. Survey-weighted Cox model | Notes

Last update: 2026-10-03
Started: 2026-09-30

NHANES Mortality Linkage: A Complete Workflow
Overview | Package options | Background: NHANES structure | 1. What cycles and files are available? | 2. Discover variables | 3. Download laboratory data | 4. Download questionnaire data | 5. Harmonize across cycles | 6. Recode questionnaire variables | 7. Stack demographics and merge all components | 8. Link mortality and prepare the survival dataset | 9. Survey-weighted Cox model | Choosing the correct survey weight | Pooling across cycles | Notes on data management | Cross-cycle variable harmonization | SEQN is a character identifier | NHANES questionnaire coding | Notes on the public-use LMF

Last update: 2026-08-25
Started: 2026-05-26

Survey-Weighted Survival Analysis: Fusing svycoxph and rms
Background and Motivation | Why not just use cph()? | Why not just use svycoxph()? | The fusion approach | Key references | Step 1: Examine object structures | Comparing weighted and unweighted estimates | Step 2: Identify Design slot dependencies | Step 3: Implement the fusion | Comparing anova.rms() output: survey-correct vs naive | Step 4: Survey-weighted baseline hazard | Step 5: Degrees of freedom correction | Conclusions and current limitations | What works | Empirical demonstration of design effects | When survey weighting is and is not necessary | Current limitations | The nhanesR package | A broader methodological agenda | Session information

Last update: 2026-08-25
Started: 2026-06-23

Getting Started with nhanesR
What nhanesR does | Installation | Setup and options | Default cache location | Permanent configuration via .Rprofile | Checking and changing settings interactively | Function map | Stage 1 — Discovery | Stage 2 — Variable search | Stage 3 — Download | Stage 4 — Harmonize and stack | Stage 5 — Mortality linkage | Stage 6 — Survival analysis preparation | Cache management | Typical workflow | Further reading

Last update: 2026-08-24
Started: 2026-05-28

Comparing Survival Frameworks: Cox, Piecewise Exponential, and mgcv-Poisson
Motivation | Key references | Notation | Cox: the partial-likelihood contribution | Piecewise exponential: the Poisson-trick contribution | Profiling out $\alpha_k$ recovers Cox | mgcv-Poisson (PAMM): the same contribution, a penalized $\alpha_k$ | Side-by-side comparison | Design weights: why the effect on β differs from the effect on marginal means | The marginal case: weighted mean as an intercept-only estimating equation | The conditional case: Binder's (1992) weighted partial likelihood | Why the numerator doesn't need weighting but the denominator does | A runnable numeric demonstration | Convergence of PEM toward Cox as $K \to \infty$ | Baseline cumulative hazard: three estimates, one true curve | Design weights: conditional robustness vs. marginal sensitivity | Discussion | Current limitations of this document | Session information

Last update: 2026-08-09
Started: 2026-08-09

Navigating Variable Name Changes and Analyte Gaps in NHANES
The problem | The quality gap in published NHANES research | Two structural barriers to full-cycle, properly-weighted analyses | A pragmatic, hypothesis-first approach | The analytic panel | The CDC catalog gap for 1999–2002 BIOPRO data | Step 1: Discovering where an analyte lives | Example 1: A well-behaved analyte | Example 2: A variable with a prefix change | Example 3: An analyte missing from one cycle | Example 4: An analyte confined to a few cycles | Example 5: A questionnaire variable with a case change | Step 2: Downloading with automatic harmonisation | Downloading ALP across all available cycles | Downloading ALT across all available cycles | Downloading AST across its available cycles | Downloading the questionnaire variable with a case change | Example 6: Disambiguation by component — serum versus urine albumin | Step 3: Assembling the multi-analyte base | Step 4: Derived variables | What the manual approach looks like | Using nhanesR with AI coding assistants | Further reading | Summary of functions used | Session information

Last update: 2026-06-23
Started: 2026-06-02

Urinary Albumin-to-Creatinine Ratio Across NHANES Cycles
Overview | Step 1 — Locate the variables | Step 2 — Download and stack | Step 3 — Calculate UACR | Step 4 — Method comparability and bridging | Known method changes | Bridging equations for serum creatinine | Step 5 — Survival analysis with survey weights | Notes and caveats | See also

Last update: 2026-06-23
Started: 2026-06-23

Readme and manuals

Help Manual

Help pageTopics
Tabulate deaths, person-years and crude mortality ratesmortality_tabulation
NHANES-annotated variable descriptionsNH_describe
Attach CDC variable descriptions as Hmisc-style labelsNH_label
Get or set the nhanesR local cache directorynhanes_cache_dir
List available NHANES cyclesnhanes_cycles
Download and cache NHANES XPT data filesnhanes_download
Download NHANES files for an analyte using the CDC variable catalognhanes_download_analyte
Summarize mortality follow-up by cyclenhanes_followup_summary
Harmonize variable names across NHANES cycles and stack into one data framenhanes_harmonize
List NHANES cycles with a public-use LMFnhanes_lmf_cycles
List available files for a NHANES cycle and componentnhanes_manifest
Merge NHANES component data frames by SEQNnhanes_merge
Download NHANES Public-Use Linked Mortality Filesnhanes_mortality_download
Link mortality data onto an NHANES analytic datasetnhanes_mortality_link
Parse NHANES Linked Mortality Files into data framesnhanes_mortality_parse
Search NHANES variables by keywordnhanes_search_variables
Stack NHANES data across multiple cyclesnhanes_stack
Prepare an NHANES-LMF dataset for survival analysisnhanes_survival_prep
Lookup table for UCOD_LEADING cause-of-death codesnhanes_ucod_labels
Build a per-cycle variable map for an analytenhanes_variable_map
Download NHANES III files into the nhanesR cachenhanes3_download
List the NHANES III data files and their CDC addressesnhanes3_files
The variables in an NHANES III file: names, labels and column positionsnhanes3_layout
Read chosen columns of an NHANES III filenhanes3_read
List NHIS survey years with Household/Person data availablenhis_data_years
Download and parse an NHIS Household or Person filenhis_download
List NHIS survey years with a public-use LMFnhis_lmf_years
Download NHIS Public-Use Linked Mortality Filesnhis_mortality_download
Link NHIS mortality data onto an NHIS analytic datasetnhis_mortality_link
Parse NHIS Linked Mortality Files into data framesnhis_mortality_parse
Fuse svycoxph and cph objects for rms ecosystem compatibilitysvycph_fuse
Substitute weighted baseline hazard into a fused cph objectsvycph_set_basehaz
Pivot a mortality tabulation into a two-way gridtabulation_grid
Compute survey-weighted cumulative baseline hazard with varianceweighted_basehaz