Package 'COVIDIBGE'

Title: Downloading, Reading and Analyzing PNAD COVID19 Microdata
Description: Provides tools for downloading, reading and analyzing the COVID19 National Household Sample Survey - PNAD COVID19, a household survey from Brazilian Institute of Geography and Statistics - IBGE. The data must be downloaded from the official website <https://www.ibge.gov.br/>. Further analysis must be made using package 'survey'.
Authors: Gabriel Assuncao [aut, cre], Luna Hidalgo [aut], Douglas Braga [ctb], Viviane Quintaes [ctb]
Maintainer: Gabriel Assuncao <[email protected]>
License: GPL-3
Version: 0.2.2
Built: 2025-01-27 03:09:51 UTC
Source: https://github.com/gabriel-assuncao/covidibge

Help Index


Add deflator variables to PNAD COVID19 microdata

Description

This function adds deflator variables to PNAD COVID19 microdata. For deflation of income variables, the documentation provided through the following address must be used: https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_PNAD_COVID19/Microdados/Documentacao/COVIDIBGE_Deflator.pdf.

Usage

covid_deflator(data_covid, deflator.file)

Arguments

data_covid

A tibble of PNAD COVID19 microdata read with read_covid function.

deflator.file

The deflator file for selected survey available on official website: (select the deflator zip file) - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_PNAD_COVID19/Microdados/Documentacao/.

Value

A tibble with the data provided from PNAD COVID19 survey and the deflator variables added for use.

Note

For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.

See Also

get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
read_covid for reading PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example for getting the path of the PNAD COVID19 toy example files.

Examples

# Using data read from disk
data_path <- covid_example(path="exampledata.csv")
dictionary.path <- covid_example(path="dictionaryexample.xls")
deflator.path <- covid_example(path="deflatorexample.xls")
covid.df <- read_covid(microdata=data_path, vars=c("C001","C002"))
covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path)
covid.df <- covid_deflator(data_covid=covid.df, deflator.file=deflator.path)

# Downloading data
covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"),
                       labels=TRUE, deflator=FALSE, design=FALSE,
                       reload=TRUE, curlopts=list(), savedir=tempdir())
deflator.path2 <- covid_example(path="deflatorexample.xls")
covid.df2 <- covid_deflator(data_covid=covid.df2, deflator.file=deflator.path2)

Create PNAD COVID19 survey object with its sample design

Description

This function creates PNAD COVID19 survey object with its sample design for analysis using survey package functions.

Usage

covid_design(data_covid)

Arguments

data_covid

A tibble of PNAD COVID19 microdata read with read_covid function.

Value

An object of class survey.design or svyrep.design with the data from PNAD COVID19 and its sample design.

Note

For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.

See Also

get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
read_covid for reading PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_example for getting the path of the PNAD COVID19 toy example files.

Examples

# Using data read from disk
data_path <- covid_example(path="exampledata.csv")
dictionary.path <- covid_example(path="dictionaryexample.xls")
deflator.path <- covid_example(path="deflatorexample.xls")
covid.df <- read_covid(microdata=data_path, vars=c("C001","C002"))
covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path)
covid.df <- covid_deflator(data_covid=covid.df, deflator.file=deflator.path)

covid.svy <- covid_design(data_covid=covid.df)
# Calculating proportion of people temporarily away from work
if (!is.null(covid.svy)) survey::svymean(x=~C002, design=covid.svy, na.rm=TRUE)

# Downloading data
covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"),
                       labels=TRUE, deflator=TRUE, design=FALSE,
                       reload=TRUE, curlopts=list(), savedir=tempdir())
covid.svy2 <- covid_design(data_covid=covid.df2)
# Calculating proportion of people temporarily away from work
if (!is.null(covid.svy2)) survey::svymean(x=~C002, design=covid.svy2, na.rm=TRUE)

Get the path of the PNAD COVID19 toy example files

Description

This function provides the path of the microdata from month 5 of year 2020 of the PNAD COVID19 toy example files, loaded with this package.

Usage

covid_example(path = NULL)

Arguments

path

Name of file. If NULL, the PNAD COVID19 toy example files names will be listed.

Value

A vector with names of all the available PNAD COVID19 toy example files or the path for specific requested PNAD COVID19 toy example file.

Note

For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.

See Also

get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
read_covid for reading PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.

Examples

covid_example()
covid_example(path="exampledata.csv")
covid_example(path="dictionaryexample.xls")
covid_example(path="deflatorexample.xls")

Label categorical variables from PNAD COVID19 microdata

Description

This function labels categorical variables from PNAD COVID19 microdata.

Usage

covid_labeller(data_covid, dictionary.file)

Arguments

data_covid

A tibble of PNAD COVID19 microdata read with read_covid function.

dictionary.file

The dictionary file for selected survey available on official website: (select a dictionary xls file) - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_PNAD_COVID19/Microdados/Documentacao/.

Value

A tibble with the data provided from PNAD COVID19 survey and its categorical variables as factors with related labels.

Note

For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.

See Also

get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
read_covid for reading PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example for getting the path of the PNAD COVID19 toy example files.

Examples

# Using data read from disk
data_path <- covid_example(path="exampledata.csv")
dictionary.path <- covid_example(path="dictionaryexample.xls")
covid.df <- read_covid(microdata=data_path, vars=c("C001","C002"))
covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path)

# Downloading data
covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"),
                       labels=FALSE, deflator=FALSE, design=FALSE,
                       reload=TRUE, curlopts=list(), savedir=tempdir())
dictionary.path2 <- covid_example(path="dictionaryexample.xls")
covid.df2 <- covid_labeller(data_covid=covid.df2, dictionary.file=dictionary.path2)

Download, label, deflate and create survey design object for PNAD COVID19 microdata

Description

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

Usage

get_covid(
  year,
  month,
  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 2020. Vector not accepted.

month

The month of the year of the data to be downloaded. Must be number from 5 to 11. Vector not accepted.

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 PNAD COVID19 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/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.

See Also

read_covid for reading PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example for getting the path of the PNAD COVID19 toy example files.

Examples

covid.svy <- get_covid(year=2020, month=5, vars=c("C001","C002"),
                       labels=TRUE, deflator=TRUE, design=TRUE,
                       reload=TRUE, curlopts=list(), savedir=tempdir())
# Calculating proportion of people temporarily away from work
if (!is.null(covid.svy)) survey::svymean(x=~C002, design=covid.svy, na.rm=TRUE)

Read PNAD COVID19 microdata

Description

This function reads PNAD COVID19 microdata.

Usage

read_covid(microdata, vars = NULL)

Arguments

microdata

A comma-separated values file containing microdata from PNAD COVID19 survey, available on official website: (select a microdata file) - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_PNAD_COVID19/Microdados/Dados/.

vars

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

Value

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/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.

See Also

get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example for getting the path of the PNAD COVID19 toy example files.

Examples

data_path <- covid_example(path="exampledata.csv")
covid.df <- read_covid(microdata=data_path, vars=c("C001","C002"))