American Time Use Survey (ATUS)

Build Status Build status

The American Time Use Survey (ATUS) collects information about how we spend our time. Sampled individuals write down everything they do for a single twenty-four hour period, in ten minute intervals. Many economists use ATUS to study uncompensated work (chores and childcare), but you can use it to learn that even in the dead of night, one-twentieth of us are awake.

  • Many tables with different structures described in the user guide.

  • A complex sample survey designed to generalize to the number of person-hours in the civilian non-institutional population of the United States aged older than fourteen.

  • Released annually since 2003.

  • Administered by the Bureau of Labor Statistics.

Simplified Download and Importation

The R lodown package easily downloads and imports all available ATUS microdata by simply specifying "atus" 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( "atus" , output_dir = file.path( path.expand( "~" ) , "ATUS" ) )

lodown also provides a catalog of available microdata extracts with the get_catalog() function. After requesting the ATUS 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 ATUS microdata files
atus_cat <-
    get_catalog( "atus" ,
        output_dir = file.path( path.expand( "~" ) , "ATUS" ) )

# 2015 only
atus_cat <- subset( atus_cat , directory == 2015 )
# download the microdata to your local computer
lodown( "atus" , atus_cat )

Analysis Examples with the survey library

Construct a complex sample survey design:

options( survey.replicates.mse = TRUE )
library(survey)

atusact <- readRDS( file.path( path.expand( "~" ) , "ATUS" , "2015/atusact.rds" ) )
atusact <- atusact[ c( 'tucaseid' , 'tutier1code' , 'tutier2code' , 'tuactdur24' ) ]

atusresp <- readRDS( file.path( path.expand( "~" ) , "ATUS" , "2015/atusresp.rds" ) )
atusresp <- atusresp[ c( 'tucaseid' , 'tufinlwgt' , 'tulineno' ) ]

atusrost <- readRDS( file.path( path.expand( "~" ) , "ATUS" , "2015/atusrost.rds" ) )
atusrost <- atusrost[ , c( 'tucaseid' , 'tulineno' , 'teage' , 'tesex' ) ]

atuswgts <- readRDS( file.path( path.expand( "~" ) , "ATUS" , "2015/atuswgts.rds" ) )
atuswgts <- atuswgts[ , c( 1 , grep( 'finlwgt' , names( atuswgts ) ) ) ]

# looking at the 2012 lexicon, travel-related activities
# have a tier 1 code of 18 --
# http://www.bls.gov/tus/lexiconnoex2012.pdf#page=22

# for all records where the tier 1 code is 18 (travel)
# replace that tier 1 of 18 with whatever's stored in tier 2
atusact[ atusact$tutier1code == 18 , 'tutier1code' ] <- atusact[ atusact$tutier1code == 18 , 'tutier2code' ]
# this will distribute all travel-related activities
# to the appropriate tier 1 category, which matches
# the structure of the 2012 bls table available at
# http://www.bls.gov/tus/tables/a1_2012.pdf

# sum up activity duration at the respondent-level
# *and* also the tier 1 code level
# (using tucaseid as the unique identifier)
# from the activities file
x <- aggregate( tuactdur24 ~ tucaseid + tutier1code , data = atusact , sum )

# now table `x` contains
# one record per person per major activity category

# reshape this data from "long" to "wide" format,
# creating a one-record-per-person table
y <- reshape( x , idvar = 'tucaseid' , timevar = 'tutier1code' , direction = 'wide' )

y[ is.na( y ) ] <- 0
# convert all missings to zeroes,
# since those individuals simply did not
# engage in those activities during their interview day
# (meaning they should have zero minutes of time)

# except for the first column (the unique identifier,
# replace each column by the quotient of itself and sixty
y[ , -1 ] <- y[ , -1 ] / 60
# now you've got an activity file `y`
# with one record per respondent

# merge together the data.frame objects with all needed columns
# in order to create a replicate-weighted survey design object

# merge the respondent file with the newly-created activity file
# (which, remember, is also one-record-per-respondent)
resp_y <- merge( atusresp , y )

# confirm that the result of the merge has the same number of records
# as the original bls atus respondent file. (this is a worthwhile check)
stopifnot( nrow( resp_y ) == nrow( atusresp ) )

# merge that result with the roster file
# note that the roster file has multiple records per `tucaseid`
# but only the `tulineno` columns equal to 1 will match
# records in the original respondent file, this merge works.
resp_y_rost <- merge( resp_y , atusrost )

# confirm that the result of the merge has the same number of records
stopifnot( nrow( resp_y_rost ) == nrow( atusresp ) )

# merge that result with the replicate weights file
z <- merge( resp_y_rost , atuswgts )

# confirm that the result of the merge has the same number of records
stopifnot( nrow( z ) == nrow( atusresp ) )

# remove dots from column names
names( z ) <- gsub( "\\." , "_" , names( z ) )

# add a column of ones
z$one <- 1

atus_design <- 
    svrepdesign(
        weights = ~tufinlwgt ,
        repweights = "finlwgt[1-9]" , 
        type = "Fay" , 
        rho = ( 1 - 1 / sqrt( 4 ) ) ,
        data = z
    )

Variable Recoding

Add new columns to the data set:

atus_design <-
    update(
        atus_design ,
        any_care = as.numeric( tuactdur24_3 > 0 ) ,
        age_category = 
            factor( 
                1 + findInterval( teage , c( 18 , 35 , 65 ) ) , 
                labels = c( "under 18" , "18 - 34" , "35 - 64" , "65 or older" ) 
            )
    )
# caring for and helping household members row
# which we know is top level 03 from
# http://www.bls.gov/tus/lexiconnoex2012.pdf

Unweighted Counts

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

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

svyby( ~ one , ~ age_category , atus_design , unwtd.count )

Weighted Counts

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

svytotal( ~ one , atus_design )

svyby( ~ one , ~ age_category , atus_design , svytotal )

Descriptive Statistics

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

svymean( ~ tuactdur24_1 , atus_design )

svyby( ~ tuactdur24_1 , ~ age_category , atus_design , svymean )

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

svymean( ~ tesex , atus_design )

svyby( ~ tesex , ~ age_category , atus_design , svymean )

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

svytotal( ~ tuactdur24_1 , atus_design )

svyby( ~ tuactdur24_1 , ~ age_category , atus_design , svytotal )

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

svytotal( ~ tesex , atus_design )

svyby( ~ tesex , ~ age_category , atus_design , svytotal )

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

svyquantile( ~ tuactdur24_1 , atus_design , 0.5 )

svyby( 
    ~ tuactdur24_1 , 
    ~ age_category , 
    atus_design , 
    svyquantile , 
    0.5 ,
    ci = TRUE ,
    keep.var = TRUE 
)

Estimate a ratio:

svyratio( 
    numerator = ~ tuactdur24_5 , 
    denominator = ~ tuactdur24_12 , 
    atus_design 
)

Subsetting

Restrict the survey design to any time volunteering:

sub_atus_design <- subset( atus_design , tuactdur24_15 > 0 )

Calculate the mean (average) of this subset:

svymean( ~ tuactdur24_1 , sub_atus_design )

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( ~ tuactdur24_1 , atus_design )

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

grouped_result <-
    svyby( 
        ~ tuactdur24_1 , 
        ~ age_category , 
        atus_design , 
        svymean 
    )
    
coef( grouped_result )
SE( grouped_result )
confint( grouped_result )
cv( grouped_result )

Calculate the degrees of freedom of any survey design object:

degf( atus_design )

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

svyvar( ~ tuactdur24_1 , atus_design )

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

# SRS without replacement
svymean( ~ tuactdur24_1 , atus_design , deff = TRUE )

# SRS with replacement
svymean( ~ tuactdur24_1 , atus_design , deff = "replace" )

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

svyciprop( ~ any_care , atus_design ,
    method = "likelihood" )

Regression Models and Tests of Association

Perform a design-based t-test:

svyttest( tuactdur24_1 ~ any_care , atus_design )

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

svychisq( 
    ~ any_care + tesex , 
    atus_design 
)

Perform a survey-weighted generalized linear model:

glm_result <- 
    svyglm( 
        tuactdur24_1 ~ any_care + tesex , 
        atus_design 
    )

summary( glm_result )

0.6 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 ATUS users, this code replicates previously-presented examples:

library(srvyr)
atus_srvyr_design <- as_survey( atus_design )

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

atus_srvyr_design %>%
    summarize( mean = survey_mean( tuactdur24_1 ) )

atus_srvyr_design %>%
    group_by( age_category ) %>%
    summarize( mean = survey_mean( tuactdur24_1 ) )

Replication Example