DOI: 10.7910/dvn/elekoy
title: Health and Retirement Study (HRS)

description: &lt;h3 class="post-title entry-title" itemprop="name"&gt; analyze the health and retirement study (hrs) with r &lt;/h3&gt; the hrs is the one and only longitudinal survey of american seniors. with a panel starting its third decade, the current pool of respondents includes older folks who have been interviewed every two years as far back as 1992. unlike &lt;a href="http://en.wikipedia.org/wiki/Cross-sectional_study"&gt;cross-sectional&lt;/a&gt; or shorter panel surveys, respondents keep responding until, well, death d
o us part. paid for by &lt;a href="http://www.nia.nih.gov/"&gt;the national institute on aging&lt;/a&gt; and administered by the university of michigan's &lt;a href="http://www.isr.umich.edu/home/"&gt;institute for social research&lt;/a&gt;, if you apply for an interviewer job with them, i hope you like werther's original.&lt;br /&gt; &lt;br /&gt; figuring out how to analyze this data set might trigger your &lt;a href="http://en.wikipedia.org/wiki/Fight-or-flight_response"&gt;fight-or-flight&lt;/a&gt; synapses if you just start clicking arou
nd on michigan's website. instead, read pages numbered 10-17 (pdf pages 12-19) of
&lt;a href="http://hrsonline.isr.umich.edu/sitedocs/databook/HRS_Text_WEB_intro.pdf"&gt;this introduction pdf&lt;/a&gt; and don't touch the data until you understand figure a-3 on that last page. if you start enjoying yourself, here's &lt;a href="http://hrsonline.isr.umich.edu/index.php?p=dbook"&gt;the whole book&lt;/a&gt;. after that, it's time to &lt;a href="https://ssl.isr.umich.edu/hrs/reg_pub2.php"&gt;register&lt;/a&gt; for access to the (free) data. keep your username and password handy, you'll need it for the top of the
download automation r script. next, look at this &lt;a href="http://hrsonline.isr.umich.edu/index.php?p=dflow"&gt;data flowchart&lt;/a&gt; to get an idea of why the &lt;a href="https://ssl.isr.umich.edu/hrs/files2.php"&gt;data download&lt;/a&gt; page is such a righteous jungle. but wait, good news: umich recently farmed out its data management to &lt;a href="http://www.rand.org/"&gt;the rand corporation&lt;/a&gt;, who promptly constructed &lt;a href="http://www.rand.org/labor/aging/dataprod.html"&gt;a giant consolidated file&lt;/a&gt; with
one record per respondent across the whole panel. oh so beautiful. the rand hrs
files make much of the older data and syntax examples obsolete, so when you come across stuff like
&lt;a href="http://hrsonline.isr.umich.edu/sitedocs/dmgt/ElementaryCookbook.pdf"&gt;instructions on how to merge years&lt;/a&gt;, you can happily ignore them - rand has done it for you.&lt;br /&gt; &lt;br /&gt; the health and retirement study only includes noninstitutionalized adults when new respondents get added to the panel (as they were in &lt;a href="http://hrsonline.isr.umich.edu/index.php?p=howsite&amp;jumpfrom=HG"&gt;1992, 1993, 1998, 2004, and 2010&lt;/a&gt;) but once they're in, they're in - respondents have a weight of
zero for interview waves when they were nursing home residents; but they're still responding and will continue to contribute to your statistics so long as you're generalizing about a population from a previous wave (for example: it's possible to compute "among all americans who were 50+ years old in 1998, x% lived in nursing homes by 2010"). my source for that 411?
&lt;a href="http://hrsonline.isr.umich.edu/sitedocs/surveydesign.pdf"&gt;page 13 of the design doc&lt;/a&gt;. wicked. this new github repository contains five scripts:&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;b&gt;1992 - 2010 download HRS microdata.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;loop through every year and every file, &lt;a href="http://www.inside-r.org/packages/cran/httr/docs/GET"&gt;download&lt;/a&gt;, then &lt;a href="http://stat.ethz.ch/R-manual/R-devel/library/utils/html/unzip.html"&gt;unzip&lt;/a&gt; everything in one big party &lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;impor
t longitudinal RAND contributed files.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;create a &lt;a href="http://cran.r-project.org/web/packages/RSQLite/RSQLite.pdf"&gt;SQLite&lt;/a&gt; database (.db) on the local disk&lt;/li&gt; &lt;li&gt;load the rand, rand-cams, and both rand-family files into the database (.db) in chunks (to prevent overloading ram)&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;longitudinal RAND - analysis examples.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;connect to the sql database created by the 'import longitudinal RAND contributed files' program&lt;/li&gt; &lt;li&gt;create tw
o &lt;a href="http://faculty.washington.edu/tlumley/survey/svy-dbi.html"&gt;database-backed&lt;/a&gt; complex sample survey object, using a &lt;a href="http://faculty.washington.edu/tlumley/survey/html/svydesign.html"&gt;taylor-series linearization design&lt;/a&gt;&lt;/li&gt; &lt;li&gt;perform a mountain of analysis examples with wave weights from two different points in the panel&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;import example HRS file.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;load a fixed-width file using only the sas importation script directly into ram with &lt;
a href="http://blog.revolutionanalytics.com/2012/07/importing-public-data-with-sas-instructions-into-r.html"&gt;SAScii
&lt;/a&gt;&lt;/li&gt; &lt;li&gt;parse through the IF block at the bottom of the sas importation script, blank out a number of variables&lt;/li&gt; &lt;li&gt;&lt;a href="http://stat.ethz.ch/R-manual/R-patched/library/base/html/save.html"&gt;save&lt;/a&gt; the file as an R data file (.rda) for fast loading later&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;replicate 2002 regression.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;connect to the sql database created by the 'import longitudinal RAND contributed files' program&lt;/li&gt; &lt;li&gt;create a &lt;a href="http://faculty.washington.edu/tlumley/s
urvey/svy-dbi.html"&gt;database-backed&lt;/a&gt; complex sample survey object, using a &lt;a href="http://faculty.washington.edu/tlumley/survey/html/svydesign.html"&gt;taylor-series linearization design&lt;/a&gt;&lt;/li&gt; &lt;li&gt;exactly match the final regression shown in &lt;a href="https://github.com/ajdamico/usgsd/blob/master/Health%20and%20Retirement%20Study/HRS%20stata%20output%20on%20current%20data%20from%20RAND.pdf?raw=true"&gt;this document&lt;/a&gt; provided by analysts at RAND as an update of the regression on &lt;a href="http:
//hrsonline.isr.umich.edu/sitedocs/dmgt/IntroUserGuide.pdf"&gt;pdf page B76 of this document
&lt;/a&gt;.&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;a href="https://github.com/ajdamico/usgsd/tree/master/Health%20and%20Retirement%20Study"&gt;click here to view these five scripts&lt;/a&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; for more detail about the health and retirement study (hrs), visit:&lt;br /&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://hrsonline.isr.umich.edu/"&gt;michigan's hrs homepage&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://hrsonline.isr.umich.edu/modules/meta/rand/index.html"&gt;rand's hrs homepage&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/
Health_and_Retirement_Study"&gt;the hrs wikipedia page&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="http://hrsonline.isr.umich.edu/index.php?p=pubs"&gt;a running list of publications using hrs&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; notes:&lt;br /&gt; &lt;br /&gt; exemplary work making it this far. as a reward, here's &lt;a href="http://hrsonline.isr.umich.edu/modules/meta/rand/randhrsl/randhrsL.pdf"&gt;the detailed codebook for the main rand hrs file&lt;/a&gt;. note that rand also creates 'flat files' for every survey wave, but really, most every analysis you c
an think of is possible using just the four files imported with the rand importation script above. if you must work with the non-rand files, there's an example of how to import a single hrs (umich-created) file, but if you wish to import more than one, you'll have to write some
&lt;a href="http://www.screenr.com/WgH8"&gt;for loops&lt;/a&gt; yourself. &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; confidential to sas, spss, stata, and sudaan users: a tidal wave is coming. you can get water up your nose and be dragged out to sea, or you can grab a surf board. time to transition to r. :D &lt;br /&gt; &lt;br /&gt;