National Longitudinal Study of Adolescent to Adult Health (ADDHEALTH)

Build Status Build status

The National Longitudinal Study of Adolescent to Adult Health follows a cohort of teenagers from the 1990s into adulthood.

  • Many tables, most with one row per sampled youth respondent.

  • A complex sample survey designed to generalize to adolescents in grades 7-12 in the United States during the 1994-95 school year.

  • Released at irregular intervals, with 1994-1995, 1996, 2001-2002, and 2008-2009 available and 2016-2018 forthcoming.

  • Administered by the Carolina Population Center and funded by a consortium.

Simplified Download and Importation

The R lodown package easily downloads and imports all available ADDHEALTH microdata by simply specifying "addhealth" with an output_dir = parameter in the lodown() function. Depending on your internet connection and computer processing speed, you might prefer to run this step overnight.

library(lodown)
lodown( "addhealth" , output_dir = file.path( path.expand( "~" ) , "ADDHEALTH" ) , 
    your_email = "email@address.com" , 
    your_password = "password" )

lodown also provides a catalog of available microdata extracts with the get_catalog() function. After requesting the ADDHEALTH catalog, you could pass a subsetted catalog through the lodown() function in order to download and import specific extracts (rather than all available extracts).

library(lodown)
# examine all available ADDHEALTH microdata files
addhealth_cat <-
    get_catalog( "addhealth" ,
        output_dir = file.path( path.expand( "~" ) , "ADDHEALTH" ) , 
        your_email = "email@address.com" , 
        your_password = "password" )

# wave i only
addhealth_cat <- subset( addhealth_cat , wave == "wave i" )
# download the microdata to your local computer
lodown( "addhealth" , addhealth_cat , 
    your_email = "email@address.com" , 
    your_password = "password" )

Analysis Examples with the survey library

Construct a complex sample survey design:

options( survey.lonely.psu = "adjust" )

library(survey)

addhealth_df <- 
    readRDS( 
        file.path( path.expand( "~" ) , "ADDHEALTH" , 
        "wave i/wave i consolidated.rds" ) 
    )

addhealth_design <- 
    svydesign( 
        id = ~cluster2 , 
        data = addhealth_df , 
        weights = ~ gswgt1 , 
        nest = TRUE 
    )

Variable Recoding

Add new columns to the data set:

addhealth_design <- 
    update( 
        addhealth_design , 
        
        one = 1 ,
        
        male = as.numeric( as.numeric( bio_sex ) == 1 ) ,
        
        how_many_hours_of_computer_games = ifelse( h1da10 > 99 , NA , h1da10 ) ,
        
        how_many_hours_of_television = ifelse( h1da8 > 99 , NA , h1da8 )
        
    )

Unweighted Counts

Count the unweighted number of records in the survey sample, overall and by groups:

sum( weights( addhealth_design , "sampling" ) != 0 )

svyby( ~ one , ~ h1gh25 , addhealth_design , unwtd.count )

Weighted Counts

Count the weighted size of the generalizable population, overall and by groups:

svytotal( ~ one , addhealth_design )

svyby( ~ one , ~ h1gh25 , addhealth_design , svytotal )

Descriptive Statistics

Calculate the mean (average) of a linear variable, overall and by groups:

svymean( ~ how_many_hours_of_computer_games , addhealth_design , na.rm = TRUE )

svyby( ~ how_many_hours_of_computer_games , ~ h1gh25 , addhealth_design , svymean , na.rm = TRUE )

Calculate the distribution of a categorical variable, overall and by groups:

svymean( ~ h1gh24 , addhealth_design , na.rm = TRUE )

svyby( ~ h1gh24 , ~ h1gh25 , addhealth_design , svymean , na.rm = TRUE )

Calculate the sum of a linear variable, overall and by groups:

svytotal( ~ how_many_hours_of_computer_games , addhealth_design , na.rm = TRUE )

svyby( ~ how_many_hours_of_computer_games , ~ h1gh25 , addhealth_design , svytotal , na.rm = TRUE )

Calculate the weighted sum of a categorical variable, overall and by groups:

svytotal( ~ h1gh24 , addhealth_design , na.rm = TRUE )

svyby( ~ h1gh24 , ~ h1gh25 , addhealth_design , svytotal , na.rm = TRUE )

Calculate the median (50th percentile) of a linear variable, overall and by groups:

svyquantile( ~ how_many_hours_of_computer_games , addhealth_design , 0.5 , na.rm = TRUE )

svyby( 
    ~ how_many_hours_of_computer_games , 
    ~ h1gh25 , 
    addhealth_design , 
    svyquantile , 
    0.5 ,
    ci = TRUE ,
    keep.var = TRUE ,
    na.rm = TRUE
)

Estimate a ratio:

svyratio( 
    numerator = ~ how_many_hours_of_computer_games , 
    denominator = ~ how_many_hours_of_television , 
    addhealth_design ,
    na.rm = TRUE
)

Subsetting

Restrict the survey design to self-reported fair or poor health:

sub_addhealth_design <- subset( addhealth_design , as.numeric( h1gh1 ) %in% c( 4 , 5 ) )

Calculate the mean (average) of this subset:

svymean( ~ how_many_hours_of_computer_games , sub_addhealth_design , na.rm = TRUE )

Measures of Uncertainty

Extract the coefficient, standard error, confidence interval, and coefficient of variation from any descriptive statistics function result, overall and by groups:

this_result <- svymean( ~ how_many_hours_of_computer_games , addhealth_design , na.rm = TRUE )

coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )

grouped_result <-
    svyby( 
        ~ how_many_hours_of_computer_games , 
        ~ h1gh25 , 
        addhealth_design , 
        svymean ,
        na.rm = TRUE 
    )
    
coef( grouped_result )
SE( grouped_result )
confint( grouped_result )
cv( grouped_result )

Calculate the degrees of freedom of any survey design object:

degf( addhealth_design )

Calculate the complex sample survey-adjusted variance of any statistic:

svyvar( ~ how_many_hours_of_computer_games , addhealth_design , na.rm = TRUE )

Include the complex sample design effect in the result for a specific statistic:

# SRS without replacement
svymean( ~ how_many_hours_of_computer_games , addhealth_design , na.rm = TRUE , deff = TRUE )

# SRS with replacement
svymean( ~ how_many_hours_of_computer_games , addhealth_design , na.rm = TRUE , deff = "replace" )

Compute confidence intervals for proportions using methods that may be more accurate near 0 and 1. See ?svyciprop for alternatives:

svyciprop( ~ male , addhealth_design ,
    method = "likelihood" )

Regression Models and Tests of Association

Perform a design-based t-test:

svyttest( how_many_hours_of_computer_games ~ male , addhealth_design )

Perform a chi-squared test of association for survey data:

svychisq( 
    ~ male + h1gh24 , 
    addhealth_design 
)

Perform a survey-weighted generalized linear model:

glm_result <- 
    svyglm( 
        how_many_hours_of_computer_games ~ male + h1gh24 , 
        addhealth_design 
    )

summary( glm_result )

0.2 Analysis Examples with srvyr

The R srvyr library calculates summary statistics from survey data, such as the mean, total or quantile using dplyr-like syntax. srvyr allows for the use of many verbs, such as summarize, group_by, and mutate, the convenience of pipe-able functions, the tidyverse style of non-standard evaluation and more consistent return types than the survey package. This vignette details the available features. As a starting point for ADDHEALTH users, this code replicates previously-presented examples:

library(srvyr)
addhealth_srvyr_design <- as_survey( addhealth_design )

Calculate the mean (average) of a linear variable, overall and by groups:

addhealth_srvyr_design %>%
    summarize( mean = survey_mean( how_many_hours_of_computer_games , na.rm = TRUE ) )

addhealth_srvyr_design %>%
    group_by( h1gh25 ) %>%
    summarize( mean = survey_mean( how_many_hours_of_computer_games , na.rm = TRUE ) )

Replication Example