get_pnds {PNDSIBGE}R Documentation

Download, label, deflate and create survey design object for PNDS microdata

Description

Core function of package. With this function only, the user can download a PNDS microdata from a year and get a sample design object ready to use with survey package functions.

Usage

get_pnds(
  year,
  section = "Female",
  vars = NULL,
  labels = TRUE,
  deflator = TRUE,
  design = TRUE,
  reload = TRUE,
  curlopts = list(),
  savedir = tempdir()
)

Arguments

year

The year of the data to be downloaded. Must be a number equal to 2023. Vector not accepted.

section

Argument corresponding to which section of the questionnaire will be obtained, being able to receive only the values of "Female" or "Male", the writing of the value must be identical to the indicated value. Default is to use the "Female" section of the questionnaire.

vars

Vector of variable names to be kept for analysis. Default is to keep all variables.

labels

Logical value. If TRUE, categorical variables will presented as factors with labels corresponding to the survey's dictionary.

deflator

Logical value. If TRUE, deflator variables will be available for use in the microdata.

design

Logical value. If TRUE, will return an object of class survey.design or svyrep.design. It is strongly recommended to keep this parameter as TRUE for further analysis. If FALSE, only the microdata will be returned.

reload

Logical value. If TRUE, will re-download the files even if they already exist in the save directory. If FALSE, will be checked if the files already exist in the save directory and the download will not be performed repeatedly, be careful with coinciding names of microdata files.

curlopts

A named list object identifying the curl options for the handle when using functions from RCurl package.

savedir

Directory to save the downloaded data. Default is to use a temporary directory.

Value

An object of class survey.design or svyrep.design with the data from PNDS and its sample design, or a tibble with selected variables of the microdata, including the necessary survey design ones.

Note

For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/sociais/saude/9160-pesquisa-nacional-de-demografia-e-saude.html?=&t=o-que-e> and consult the other functions of this package, described below.

See Also

read_pnds for reading PNDS microdata.
pnds_labeller for labeling categorical variables from PNDS microdata.
pnds_deflator for adding deflator variables to PNDS microdata.
pnds_design for creating PNDS survey design object.
pnds_example for getting the path of the PNDS toy example files.

Examples


pnds.svy <- get_pnds(year=2023, section="Female", vars=c("J007","J009"),
                       labels=TRUE, deflator=TRUE, design=TRUE,
                       reload=TRUE, curlopts=list(), savedir=tempdir())
# Calculating proportion of people diagnosed with chronic diseases
if (!is.null(pnds.svy)) survey::svymean(x=~J007, design=pnds.svy, na.rm=TRUE)
pnds.svy2 <- get_pnds(year=2023, section="Male", vars=c("N001","N00101"),
                       labels=TRUE, deflator=TRUE, design=TRUE,
                       reload=TRUE, curlopts=list(), savedir=tempdir())
# Calculating proportion of people's self-rated health
if (!is.null(pnds.svy2)) survey::svymean(x=~N001, design=pnds.svy2, na.rm=TRUE)

[Package PNDSIBGE version 0.1.1 Index]