analyze the national health and nutrition examination survey (nhanes) with r

nhanes is this fascinating survey where doctors and dentists accompany survey interviewers in a little mobile medical center that drives around the country.  while the survey folks are interviewing people, the medical professionals administer laboratory tests and conduct a real doctor's examination.  the blood work and medical exam allow researchers like you and me to answer tough questions like, "how many people have diabetes but don't know they have diabetes?"

conducting the lab tests and the physical isn't cheap, so a new nhanes data set becomes available once every two years and only includes about twelve thousand respondents.  since the number of respondents is so small, analysts often pool multiple years of data together.  the replication scripts below give a few different examples of how multiple years of data can be pooled with r.

the survey gets conducted by the centers for disease control and prevention (cdc), and generalizes to the united states non-institutional, non-active duty military population.

most of the data tables produced by the cdc include only a small number of variables, so importation with the foreign package's read.xport function is pretty straightforward.  but that makes merging the appropriate data sets trickier, since it might not be clear what to pull for which variables.  for every analysis, start with the table with 'demo' in the name -- this file includes basic demographics, weighting, and complex sample survey design variables.  since it's quick to download the files directly from the cdc's ftp site, there's no massive ftp download automation script.  this new github repository contains five scripts:

2009-2010 interview only - download and analyze.R
  • download, import, save the demographics and health insurance files onto your local computer
  • load both files, limit them to the variables needed for the analysis, merge them together
  • perform a few example variable recodes
  • create the complex sample survey object, using the interview weights
  • run a series of pretty generic analyses on the health insurance questions

2009-2010 interview plus laboratory - download and analyze.R
  • download, import, save the demographics and cholesterol files onto your local computer
  • load both files, limit them to the variables needed for the analysis, merge them together
  • perform a few example variable recodes
  • create the complex sample survey object, using the mobile examination component (mec) weights
  • perform a direct-method age-adjustment and match figure 1 of this cdc cholesterol brief

replicate 2005-2008 pooled cdc oral examination figure.R

replicate cdc publications.R

replicate human exposure to chemicals report.R (user-contributed)
  • download, import, save, pool, merge, and recode the demographics file plus urinary bisphenol a (bpa) laboratory files
  • log-transform some of the columns to calculate the geometric means and quantiles
  • match the 2007-2008 statistics shown on pdf page 21 of the cdc's fourth edition of the report


click here to view these five scripts


for more detail about the national health and nutrition examination survey (nhanes), visit:


notes:

nhanes includes interview-only weights and interview + mobile examination component (mec) weights.  if you only use questions from the basic interview in your analysis, use the interview-only weights (the sample size is a bit larger).  i haven't really figured out a use for the interview-only weights -- nhanes draws most of its power from the combination of the interview and the mobile examination component variables.  if you're only using variables from the interview, see if you can use a data set with a larger sample size like the current population (cps), national health interview survey (nhis), or medical expenditure panel survey (meps) instead.


confidential to sas, spss, stata, sudaan users: why are you still riding around on a donkey after we've invented the internal combustion engine?  time to transition to r.  :D