dhs {childfree}R Documentation

Read and recode Demographic and Health Surveys (DHS) individual data

Description

Read and recode Demographic and Health Surveys (DHS) individual data

Usage

dhs(files, extra.vars = NULL, survey = FALSE, progress = TRUE)

Arguments

files

vector: a character vector containing the paths for one or more Individual Recode DHS data files (see details)

extra.vars

vector: a character vector containing the names of variables to be retained from the raw data

survey

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

progress

boolean: display a progress bar

Details

The Demographic and Health Surveys (DHS) program regularly collects health data from population-representative samples in many countries using standardized surveys since 1984. The "individual recode" data files contain women's responses, while the "men recode" files contain men's responses. These files are available in SPSS, SAS, and Stata formats from https://www.dhsprogram.com/, however access requires a free application. The dhs() function reads one or more of these files, extracts and recodes selected variables useful for studying childfree adults and other family statuses, then returns either an unweighted data frame, or a weighted svydesign object that can be analyzed using the survey package.

Although access to DHS data requires an application, the DHS program provides a model dataset for practice. The example provided below uses the model data file "ZZIR62FL.SAV", which contains fictitious women's data, but has the same structure as a real DHS data file. The example can be run without prior application for data access.

Known issues

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 <- dhs(files = c("ZZIR62FL.SAV"), extra.vars = c("v201"))  #Request unweighted data
if (!is.null(unweighted)) {  #If data was available...
round(table(unweighted$famstat)/nrow(unweighted),3)  #Fraction of respondents w/ each family status
}

weighted <- dhs(files = c("ZZIR62FL.SAV"), survey = TRUE)  #Request weighted (example) data
if (!is.null(weighted)) {  #If dtaa was available...
survey::svymean(~famstat, weighted, na.rm = TRUE)  #Estimated prevalence of each family status
}


[Package childfree version 0.0.3 Index]