DOI: 10.7910/dvn/imwqpj
title: National Health and Nutrition Examination Survey (NHANES)

description: &lt;h3 class="post-title entry-title" itemprop="name"&gt; analyze the national health and nutrition examination survey (nhanes) with r &lt;/h3&gt; 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. &lt;a href="http://www.cdc.gov/nchs/data/nhanes/meccomp.pdf"&gt;the b
lood work and medical exam&lt;/a&gt; allow researchers like you and me to answer tough questions like, "how many people have diabetes but don't know they have diabetes?"&lt;br /&gt; &lt;br /&gt; 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.&lt;br /&gt; &lt;br /&gt; the survey gets conducted by &lt;a href="http://www.cdc.gov/"&gt;the centers for disease control and prevention (cdc)&lt;/a&gt;, and generalizes to the united states non-institutional, non-active duty military population.&lt;br /&gt; &lt;br /&gt; most of the data tables produced by the cdc include only a small number of variables, so importation with the foreign package's &lt;a href="http://stat.ethz.ch/R-manual/R-devel/library/foreign/html/read.xpo
rt.html"&gt;read.xport&lt;/a&gt; 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 co
ntains five scripts:&lt;br /&gt; &lt;br /&gt; &lt;b&gt;2009-2010 interview only - download and analyze.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;download, import, save the demographics and health insurance files onto your local computer&lt;/li&gt; &lt;li&gt;load both files, limit them to the variables needed for the analysis, merge them together&lt;/li&gt; &lt;li&gt;perform a few example variable recodes&lt;/li&gt; &lt;li&gt;create the complex sample survey object, using the interview weights&lt;/li&gt; &lt;li&gt;run a series of pretty generic analyses on the health insurance ques
tions&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;2009-2010 interview plus laboratory - download and analyze.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;download, import, save the demographics and cholesterol files onto your local computer&lt;/li&gt; &lt;li&gt;load both files, limit them to the variables needed for the analysis, merge them together&lt;/li&gt; &lt;li&gt;perform a few example variable recodes&lt;/li&gt; &lt;li&gt;create the complex sample survey object, using the mobile examination component (mec) weights&lt;/li&gt; &lt;li&gt;perform a direct-method age-adjustment and matc
h &lt;a href="http://www.cdc.gov/nchs/data/databriefs/db92.pdf"&gt;figure 1 of this cdc cholesterol brief&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;replicate 2005-2008 pooled cdc oral examination figure.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;download, import, save, pool, recode, create a survey object, run some basic analyses&lt;/li&gt; &lt;li&gt;replicate &lt;a href="http://www.cdc.gov/nchs/data/databriefs/db96.pdf"&gt;figure 3 from this cdc oral health databrief&lt;/a&gt; - the whole &lt;a href="http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/barplo
t.html"&gt;barplot&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;replicate cdc publications.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;download, import, save, pool, merge, and recode the demographics file plus cholesterol laboratory, blood pressure questionnaire, and blood pressure laboratory files&lt;/li&gt; &lt;li&gt;match the cdc's example sas and sudaan syntax file's &lt;a href="http://www.cdc.gov/nchs/tutorials/nhanes/downloads/Continuous/descriptive_means_sas.pdf"&gt;output for descriptive means&lt;/a&gt;&lt;/li&gt; &lt;li&gt;match the cdc's example sas and sudaan synta
x file's &lt;a href="http://www.cdc.gov/nchs/tutorials/nhanes/downloads/Continuous/descriptive_proportion.pdf"&gt;output for descriptive proportions&lt;/a&gt;&lt;/li&gt; &lt;li&gt;match the cdc's example sas and sudaan syntax file's &lt;a href="http://www.cdc.gov/nchs/tutorials/nhanes/downloads/Continuous/descriptive_percentile.pdf"&gt;output for descriptive percentiles&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;replicate human exposure to chemicals report.R&lt;/b&gt; &lt;span style="background-color: yellow;"&gt;(user-contributed)&lt;/span&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;
download, import, save, pool, merge, and recode the demographics file plus urinary bisphenol a (bpa) laboratory files
&lt;/li&gt; &lt;li&gt;log-transform some of the columns to calculate the geo&lt;a href="http://www.cdc.gov/nchs/tutorials/nhanes/downloads/Continuous/descriptive_means_sas.pdf"&gt;&lt;/a&gt;metric means and quantiles&lt;/li&gt; &lt;li&gt;match the 2007-2008 statistics shown on pdf page 21 of &lt;a href="http://www.cdc.gov/exposurereport/pdf/FourthReport_UpdatedTables_Sep2012.pdf#page=21"&gt;the cdc's fourth edition of the report&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;br /&gt; &lt;a href="https://github.com/ajdamico/usgsd/tree/master/National%20Health%20and%2
0Nutrition%20Examination%20Survey"&gt;click here to view these five scripts
&lt;/a&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; for more detail about the national health and nutrition examination survey (nhanes), visit:&lt;br /&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.cdc.gov/nchs/nhanes.htm"&gt;the cdc's nhanes homepage&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://riskfactor.cancer.gov/tools/nhanes_tutorial.html"&gt;the national cancer institute's page of nhanes web tutorials&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;br /&gt; notes:&lt;br /&gt; &lt;br /&gt; nhanes includes interview-only weights and interview + mobile examination component (mec) weights. if you o
nly 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
&lt;a href="http://usgsd.blogspot.com/search/label/current%20population%20survey%20%28cps%29"&gt;current population (cps)&lt;/a&gt;, &lt;a href="http://usgsd.blogspot.com/search/label/national%20health%20interview%20survey%20%28nhis%29"&gt;national health interview survey (nhis)&lt;/a&gt;, or &lt;a href="http://usgsd.blogspot.com/search/label/medical%20expenditure%20panel%20survey%20%28meps%29"&gt;medical expenditure panel survey (meps)&lt;/a&gt; instead.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; 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