nsfg {childfree}R Documentation

Read and recode National Survey of Family Growth (NSFG) data

Description

Read and recode National Survey of Family Growth (NSFG) data

Usage

nsfg(years, survey = FALSE, keep_source = FALSE, progress = TRUE)

Arguments

years

vector: a numeric vector containing the starting year of NSFG waves to include (2002, 2006, 2011, 2013, 2015, 2017)

survey

boolean: returns an unweighted data.frame if FALSE, or a weighted svydesign object if TRUE

keep_source

boolean: keep the raw variables used to construct want_cf and famstat

progress

boolean: display a progress bar

Details

The U.S. Centers for Disease Control National Survey of Family Growth (NSFG) regularly collects fertility and other health information from a population-representative sample of adults in the United States. Between 1973 and 2002, the NSFG was conducted periodically. Starting in 2002, the NSFG transitioned to continuous data collection, releasing data in multi-year waves (e.g., 2006-2010, 2011-2013). The nsfg() function reads the raw data from CDC's website, extracts and recodes selected variables useful for studying childfree adults and other family statuses, then returns either an unweighted data frame, or a weighted design object that can be analyzed using the survey package.

Notes

Value

A data frame or weighted svydesign object containing variables described in the codebook available using vignette("codebooks") If you are offline, or if the requested data are otherwise unavailable, NULL is returned.

Examples


unweighted <- nsfg(years = 2017)  #Request unweighted data
if (!is.null(unweighted)) {  #If data was available...
table(unweighted$famstat) / nrow(unweighted)  #Fraction of respondents with each family status
}

weighted <- nsfg(years = 2017, survey = TRUE)  #Request weighted data
if (!is.null(weighted)) {  #If data was available...
survey::svymean(~famstat, weighted, na.rm = TRUE)  #Estimated prevalence of each family status
}


[Package childfree version 0.0.3 Index]