Behavioral Risk Factor Surveillance System (BRFSS)

Github Actions Badge

A health behavior telephone interview survey with enough sample size to examine all fifty states.

  • One table with one row per telephone respondent.

  • A complex survey designed to generalize to the civilian non-institutional adult population of the U.S.

  • Released annually since 1984 but all states did not participate until 1994.

  • Administered by the Centers for Disease Control and Prevention.


Please skim before you begin:

  1. BRFSS Data User Guide

  2. Wikipedia Entry

  3. This human-composed haiku or a bouquet of artificial intelligence-generated limericks

# a cellphone vibrates
# it's the cdc! asking
# if you ate veggies

Download, Import, Preparation

Download and import the national file:

library(haven)

zip_tf <- tempfile()

zip_url <- "https://www.cdc.gov/brfss/annual_data/2022/files/LLCP2022XPT.zip"
    
download.file( zip_url , zip_tf , mode = 'wb' )

brfss_tbl <- read_xpt( zip_tf )

brfss_df <- data.frame( brfss_tbl )

names( brfss_df ) <- tolower( names( brfss_df ) )

brfss_df[ , 'one' ] <- 1

Save locally  

Save the object at any point:

# brfss_fn <- file.path( path.expand( "~" ) , "BRFSS" , "this_file.rds" )
# saveRDS( brfss_df , file = brfss_fn , compress = FALSE )

Load the same object:

# brfss_df <- readRDS( brfss_fn )

Survey Design Definition

Construct a complex sample survey design:

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

library(survey)

variables_to_keep <-
    c( 'one' , 'x_psu' , 'x_ststr' , 'x_llcpwt' , 'genhlth' , 'medcost1' , 
    'x_state' , 'x_age80' , 'nummen' , 'numadult' , 'x_hlthpln' )
    
brfss_df <- brfss_df[ variables_to_keep ]
    
brfss_national_design <-
    svydesign(
        id = ~ x_psu ,
        strata = ~ x_ststr ,
        data = brfss_df ,
        weight = ~ x_llcpwt ,
        nest = TRUE
    )

Since large linearized survey designs execute slowly, a replication design might be preferrable for exploratory analysis. Coefficients (such as means and medians) do not change, standard errors and confidence intervals differ slightly. The initial conversion with as.svrepdesign requires an extended period of processing time (perhaps run once overnight), subsequent analyses will finish much faster:

# brfss_replication_design <-
#   as.svrepdesign( 
#       brfss_national_design ,
#       type = 'bootstrap'
#   )

# system.time( print( svymean( ~ x_age80 , brfss_national_design ) ) )

# system.time( print( svymean( ~ x_age80 , brfss_replication_design ) ) )

In this example, limit the national design to only Alaska for quicker processing:

brfss_design <-
    subset(
        brfss_national_design , 
        x_state %in% 2 
    )

Variable Recoding

Add new columns to the data set:

brfss_design <- 
    update( 
        brfss_design ,
        
        fair_or_poor_health = ifelse( genhlth %in% 1:5 , as.numeric( genhlth > 3 ) , NA ) ,
        
        no_doc_visit_due_to_cost = 
            factor( 
                medcost1 , 
                levels = c( 1 , 2 , 7 , 9 ) , 
                labels = c( "yes" , "no" , "dk" , "rf" ) 
            ) ,
        
        state_name =
        
            factor(
            
                x_state ,
                
                levels = 
                    c(1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 
                    21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 
                    37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 53, 54, 
                    55, 56, 66, 72, 78) ,
                    
                labels = 
                    c("ALABAMA", "ALASKA", "ARIZONA", "ARKANSAS", "CALIFORNIA", 
                    "COLORADO", "CONNECTICUT", "DELAWARE", "DISTRICT OF COLUMBIA", 
                    "FLORIDA", "GEORGIA", "HAWAII", "IDAHO", "ILLINOIS", "INDIANA",
                    "IOWA", "KANSAS", "KENTUCKY", "LOUISIANA", "MAINE", "MARYLAND",
                    "MASSACHUSETTS", "MICHIGAN", "MINNESOTA", "MISSISSIPPI", 
                    "MISSOURI", "MONTANA", "NEBRASKA", "NEVADA", "NEW HAMPSHIRE",
                    "NEW JERSEY", "NEW MEXICO", "NEW YORK", "NORTH CAROLINA", 
                    "NORTH DAKOTA", "OHIO", "OKLAHOMA", "OREGON", "PENNSYLVANIA",
                    "RHODE ISLAND", "SOUTH CAROLINA", "SOUTH DAKOTA", "TENNESSEE",
                    "TEXAS", "UTAH", "VERMONT", "VIRGINIA", "WASHINGTON",
                    "WEST VIRGINIA", "WISCONSIN", "WYOMING", "GUAM", "PUERTO RICO",
                    "U.S. VIRGIN ISLANDS")
                    
            )
    )

Analysis Examples with the survey library  

Unweighted Counts

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

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

svyby( ~ one , ~ state_name , brfss_design , unwtd.count )

Weighted Counts

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

svytotal( ~ one , brfss_design )

svyby( ~ one , ~ state_name , brfss_design , svytotal )

Descriptive Statistics

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

svymean( ~ x_age80 , brfss_design )

svyby( ~ x_age80 , ~ state_name , brfss_design , svymean )

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

svymean( ~ no_doc_visit_due_to_cost , brfss_design , na.rm = TRUE )

svyby( ~ no_doc_visit_due_to_cost , ~ state_name , brfss_design , svymean , na.rm = TRUE )

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

svytotal( ~ x_age80 , brfss_design )

svyby( ~ x_age80 , ~ state_name , brfss_design , svytotal )

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

svytotal( ~ no_doc_visit_due_to_cost , brfss_design , na.rm = TRUE )

svyby( ~ no_doc_visit_due_to_cost , ~ state_name , brfss_design , svytotal , na.rm = TRUE )

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

svyquantile( ~ x_age80 , brfss_design , 0.5 )

svyby( 
    ~ x_age80 , 
    ~ state_name , 
    brfss_design , 
    svyquantile , 
    0.5 ,
    ci = TRUE 
)

Estimate a ratio:

svyratio( 
    numerator = ~ nummen , 
    denominator = ~ numadult , 
    brfss_design ,
    na.rm = TRUE
)

Subsetting

Restrict the survey design to persons without health insurance:

sub_brfss_design <- subset( brfss_design , x_hlthpln == 2 )

Calculate the mean (average) of this subset:

svymean( ~ x_age80 , sub_brfss_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( ~ x_age80 , brfss_design )

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

grouped_result <-
    svyby( 
        ~ x_age80 , 
        ~ state_name , 
        brfss_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( brfss_design )

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

svyvar( ~ x_age80 , brfss_design )

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

# SRS without replacement
svymean( ~ x_age80 , brfss_design , deff = TRUE )

# SRS with replacement
svymean( ~ x_age80 , brfss_design , deff = "replace" )

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

svyciprop( ~ fair_or_poor_health , brfss_design ,
    method = "likelihood" , na.rm = TRUE )

Regression Models and Tests of Association

Perform a design-based t-test:

svyttest( x_age80 ~ fair_or_poor_health , brfss_design )

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

svychisq( 
    ~ fair_or_poor_health + no_doc_visit_due_to_cost , 
    brfss_design 
)

Perform a survey-weighted generalized linear model:

glm_result <- 
    svyglm( 
        x_age80 ~ fair_or_poor_health + no_doc_visit_due_to_cost , 
        brfss_design 
    )

summary( glm_result )

Replication Example

This example matches Alaska’s confidence intervals from the BRFSS Prevalence & Trends Data:

result <-
    svymean(
        ~ no_doc_visit_due_to_cost ,
        subset(
            brfss_design ,
            no_doc_visit_due_to_cost %in%
                c( 'yes' , 'no' )
        ) ,
        na.rm = TRUE
    )

stopifnot( round( confint( result )[ 1 , 1 ] , 3 ) == 0.092 )
stopifnot( round( confint( result )[ 1 , 2 ] , 3 ) == 0.114 )
stopifnot( round( confint( result )[ 2 , 1 ] , 3 ) == 0.886 )
stopifnot( round( confint( result )[ 2 , 2 ] , 3 ) == 0.908 )

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

library(srvyr)
brfss_srvyr_design <- as_survey( brfss_design )

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

brfss_srvyr_design %>%
    summarize( mean = survey_mean( x_age80 ) )

brfss_srvyr_design %>%
    group_by( state_name ) %>%
    summarize( mean = survey_mean( x_age80 ) )