Title: | Downloading, Reading and Analyzing PNADC Microdata |
---|---|
Description: | Provides tools for downloading, reading and analyzing the Continuous National Household Sample Survey - PNADC, 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: | Douglas Braga [aut], Gabriel Assuncao [aut, cre], Luna Hidalgo [ctb], Viviane Quintaes [ctb] |
Maintainer: | Gabriel Assuncao <[email protected]> |
License: | GPL-3 |
Version: | 0.7.5 |
Built: | 2025-03-28 04:06:08 UTC |
Source: | https://github.com/gabriel-assuncao/pnadcibge |
Core function of package. With this function only, the user can download a PNADC microdata from a year or quarter and get a sample design object ready to use with survey
package functions.
get_pnadc( year, quarter = NULL, interview = NULL, topic = NULL, selected = FALSE, vars = NULL, defyear = NULL, defperiod = NULL, labels = TRUE, deflator = TRUE, design = TRUE, reload = TRUE, curlopts = list(), savedir = tempdir() )
get_pnadc( year, quarter = NULL, interview = NULL, topic = NULL, selected = FALSE, vars = NULL, defyear = NULL, defperiod = NULL, labels = TRUE, deflator = TRUE, design = TRUE, reload = TRUE, curlopts = list(), savedir = tempdir() )
year |
The year of the data to be downloaded. Must be a number between 2012 and current year. Vector not accepted. |
quarter |
The quarter of the year of the data to be downloaded. Must be number from 1 to 4. Vector not accepted. If |
interview |
The interview number of the data to be downloaded. Must be number from 1 to 5. Vector not accepted. Using this option will get annual per interview data. If |
topic |
The quarter related to the topic of the data to be downloaded. Must be number from 1 to 4. Vector not accepted. Using this option will get annual per topic data. If |
selected |
Logical value. If |
vars |
Vector of variable names to be kept for analysis. Default is to keep all variables. |
defyear |
The year of the deflator data to be downloaded for annual microdata. Must be a number between 2017 and the last available year. Vector not accepted. If |
defperiod |
The quarter period of the deflator data to be downloaded for annual per topic microdata. Must be number from 1 to 4. Vector not accepted. If |
labels |
Logical value. If |
deflator |
Logical value. If |
design |
Logical value. If |
reload |
Logical value. If |
curlopts |
A named list object identifying the curl options for the handle when using functions from |
savedir |
Directory to save the downloaded data. Default is to use a temporary directory. |
An object of class survey.design
or svyrep.design
with the data from PNADC and its sample design, or a tibble with selected variables of the microdata, including the necessary survey design ones.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/sociais/trabalho/9171-pesquisa-nacional-por-amostra-de-domicilios-continua-mensal.html?=&t=o-que-e> and consult the other functions of this package, described below.
read_pnadc for reading PNADC microdata.
pnadc_labeller for labeling categorical variables from PNADC microdata.
pnadc_deflator for adding deflator variables to PNADC microdata.
pnadc_design for creating PNADC survey design object.
pnadc_example for getting the path of the quarter PNADC toy example files.
pnadc.svy <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"), defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE, reload=TRUE, curlopts=list(), savedir=tempdir()) # Calculating proportion of employed and unemployed people if (!is.null(pnadc.svy)) survey::svymean(x=~VD4002, design=pnadc.svy, na.rm=TRUE) pnadc.svy2 <- get_pnadc(year=2017, interview=5, selected=FALSE, vars=c("V4112","V4121B"), defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE, reload=TRUE, curlopts=list(), savedir=tempdir()) # Calculating average hours dedicated to the care of people or household chores if (!is.null(pnadc.svy2)) survey::svymean(x=~V4121B, design=pnadc.svy2, na.rm=TRUE) pnadc.svy3 <- get_pnadc(year=2017, topic=4, selected=FALSE, vars=c("S07006","S07007"), defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE, reload=TRUE, curlopts=list(), savedir=tempdir()) # Calculating proportion of cell phone for personal use with internet access if (!is.null(pnadc.svy3)) survey::svymean(x=~S07007, design=pnadc.svy3, na.rm=TRUE)
pnadc.svy <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"), defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE, reload=TRUE, curlopts=list(), savedir=tempdir()) # Calculating proportion of employed and unemployed people if (!is.null(pnadc.svy)) survey::svymean(x=~VD4002, design=pnadc.svy, na.rm=TRUE) pnadc.svy2 <- get_pnadc(year=2017, interview=5, selected=FALSE, vars=c("V4112","V4121B"), defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE, reload=TRUE, curlopts=list(), savedir=tempdir()) # Calculating average hours dedicated to the care of people or household chores if (!is.null(pnadc.svy2)) survey::svymean(x=~V4121B, design=pnadc.svy2, na.rm=TRUE) pnadc.svy3 <- get_pnadc(year=2017, topic=4, selected=FALSE, vars=c("S07006","S07007"), defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE, reload=TRUE, curlopts=list(), savedir=tempdir()) # Calculating proportion of cell phone for personal use with internet access if (!is.null(pnadc.svy3)) survey::svymean(x=~S07007, design=pnadc.svy3, na.rm=TRUE)
This function adds deflator variables to PNADC microdata. For deflation of income variables, the documentation provided through the following addresses must be used:
Quarter - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Trimestral/Microdados/Documentacao/PNADcIBGE_Deflator_Trimestral.pdf.
Annual per Interview - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Visita/Documentacao_Geral/PNADcIBGE_Deflator_Anual_Visita.pdf.
Annual per Topic - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Trimestre/Documentacao_Geral/PNADcIBGE_Deflator_Anual_Trimestre.pdf.
pnadc_deflator(data_pnadc, deflator.file)
pnadc_deflator(data_pnadc, deflator.file)
data_pnadc |
A tibble of PNADC microdata read with |
deflator.file |
The deflator file for selected survey available on official website: |
A tibble with the data provided from PNADC survey and the deflator variables added for use.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/sociais/trabalho/9171-pesquisa-nacional-por-amostra-de-domicilios-continua-mensal.html?=&t=o-que-e> and consult the other functions of this package, described below.
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
read_pnadc for reading PNADC microdata.
pnadc_labeller for labeling categorical variables from PNADC microdata.
pnadc_design for creating PNADC survey design object.
pnadc_example for getting the path of the quarter PNADC toy example files.
# Using data read from disk input_path <- pnadc_example(path="input_example.txt") data_path <- pnadc_example(path="exampledata.txt") dictionary.path <- pnadc_example(path="dictionaryexample.xls") deflator.path <- pnadc_example(path="deflatorexample.xls") pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002")) pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path) pnadc.df <- pnadc_deflator(data_pnadc=pnadc.df, deflator.file=deflator.path) # Downloading data pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"), defyear=2017, defperiod=4, labels=TRUE, deflator=FALSE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) deflator.path2 <- pnadc_example(path="deflatorexample.xls") pnadc.df2 <- pnadc_deflator(data_pnadc=pnadc.df2, deflator.file=deflator.path2)
# Using data read from disk input_path <- pnadc_example(path="input_example.txt") data_path <- pnadc_example(path="exampledata.txt") dictionary.path <- pnadc_example(path="dictionaryexample.xls") deflator.path <- pnadc_example(path="deflatorexample.xls") pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002")) pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path) pnadc.df <- pnadc_deflator(data_pnadc=pnadc.df, deflator.file=deflator.path) # Downloading data pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"), defyear=2017, defperiod=4, labels=TRUE, deflator=FALSE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) deflator.path2 <- pnadc_example(path="deflatorexample.xls") pnadc.df2 <- pnadc_deflator(data_pnadc=pnadc.df2, deflator.file=deflator.path2)
This function creates PNADC survey object with its sample design for analysis using survey
package functions.
pnadc_design(data_pnadc)
pnadc_design(data_pnadc)
data_pnadc |
A tibble of PNADC microdata read with |
An object of class survey.design
or svyrep.design
with the data from PNADC and its sample design.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/sociais/trabalho/9171-pesquisa-nacional-por-amostra-de-domicilios-continua-mensal.html?=&t=o-que-e> and consult the other functions of this package, described below.
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
read_pnadc for reading PNADC microdata.
pnadc_labeller for labeling categorical variables from PNADC microdata.
pnadc_deflator for adding deflator variables to PNADC microdata.
pnadc_example for getting the path of the quarter PNADC toy example files.
# Using data read from disk input_path <- pnadc_example(path="input_example.txt") data_path <- pnadc_example(path="exampledata.txt") dictionary.path <- pnadc_example(path="dictionaryexample.xls") deflator.path <- pnadc_example(path="deflatorexample.xls") pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002")) pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path) pnadc.df <- pnadc_deflator(data_pnadc=pnadc.df, deflator.file=deflator.path) pnadc.svy <- pnadc_design(data_pnadc=pnadc.df) # Calculating proportion of employed and unemployed people if (!is.null(pnadc.svy)) survey::svymean(x=~VD4002, design=pnadc.svy, na.rm=TRUE) # Downloading data pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"), defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) pnadc.svy2 <- pnadc_design(data_pnadc=pnadc.df2) # Calculating proportion of employed and unemployed people if (!is.null(pnadc.svy2)) survey::svymean(x=~VD4002, design=pnadc.svy2, na.rm=TRUE)
# Using data read from disk input_path <- pnadc_example(path="input_example.txt") data_path <- pnadc_example(path="exampledata.txt") dictionary.path <- pnadc_example(path="dictionaryexample.xls") deflator.path <- pnadc_example(path="deflatorexample.xls") pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002")) pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path) pnadc.df <- pnadc_deflator(data_pnadc=pnadc.df, deflator.file=deflator.path) pnadc.svy <- pnadc_design(data_pnadc=pnadc.df) # Calculating proportion of employed and unemployed people if (!is.null(pnadc.svy)) survey::svymean(x=~VD4002, design=pnadc.svy, na.rm=TRUE) # Downloading data pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"), defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) pnadc.svy2 <- pnadc_design(data_pnadc=pnadc.df2) # Calculating proportion of employed and unemployed people if (!is.null(pnadc.svy2)) survey::svymean(x=~VD4002, design=pnadc.svy2, na.rm=TRUE)
This function provides the path of the microdata from quarter 4 of year 2017 of the PNADC toy example files, loaded with this package.
pnadc_example(path = NULL)
pnadc_example(path = NULL)
path |
Name of file. If |
A vector with names of all the available quarter PNADC toy example files or the path for specific requested quarter PNADC toy example file.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/sociais/trabalho/9171-pesquisa-nacional-por-amostra-de-domicilios-continua-mensal.html?=&t=o-que-e> and consult the other functions of this package, described below.
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
read_pnadc for reading PNADC microdata.
pnadc_labeller for labeling categorical variables from PNADC microdata.
pnadc_deflator for adding deflator variables to PNADC microdata.
pnadc_design for creating PNADC survey design object.
pnadc_example() pnadc_example(path="exampledata.txt") pnadc_example(path="input_example.txt") pnadc_example(path="dictionaryexample.xls") pnadc_example(path="deflatorexample.xls")
pnadc_example() pnadc_example(path="exampledata.txt") pnadc_example(path="input_example.txt") pnadc_example(path="dictionaryexample.xls") pnadc_example(path="deflatorexample.xls")
This function labels categorical variables from PNADC microdata.
pnadc_labeller(data_pnadc, dictionary.file)
pnadc_labeller(data_pnadc, dictionary.file)
data_pnadc |
A tibble of PNADC microdata read with |
dictionary.file |
The dictionary file for selected survey available on official website: |
A tibble with the data provided from PNADC survey and its categorical variables as factors with related labels.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/sociais/trabalho/9171-pesquisa-nacional-por-amostra-de-domicilios-continua-mensal.html?=&t=o-que-e> and consult the other functions of this package, described below.
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
read_pnadc for reading PNADC microdata.
pnadc_deflator for adding deflator variables to PNADC microdata.
pnadc_design for creating PNADC survey design object.
pnadc_example for getting the path of the quarter PNADC toy example files.
# Using data read from disk input_path <- pnadc_example(path="input_example.txt") data_path <- pnadc_example(path="exampledata.txt") dictionary.path <- pnadc_example(path="dictionaryexample.xls") pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002")) pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path) # Downloading data pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"), defyear=2017, defperiod=4, labels=FALSE, deflator=FALSE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) dictionary.path2 <- pnadc_example(path="dictionaryexample.xls") pnadc.df2 <- pnadc_labeller(data_pnadc=pnadc.df2, dictionary.file=dictionary.path2)
# Using data read from disk input_path <- pnadc_example(path="input_example.txt") data_path <- pnadc_example(path="exampledata.txt") dictionary.path <- pnadc_example(path="dictionaryexample.xls") pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002")) pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path) # Downloading data pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"), defyear=2017, defperiod=4, labels=FALSE, deflator=FALSE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) dictionary.path2 <- pnadc_example(path="dictionaryexample.xls") pnadc.df2 <- pnadc_labeller(data_pnadc=pnadc.df2, dictionary.file=dictionary.path2)
This function reads PNADC microdata.
read_pnadc(microdata, input_txt, vars = NULL)
read_pnadc(microdata, input_txt, vars = NULL)
microdata |
A text file containing microdata from PNADC survey, available on official website: |
input_txt |
A text file, related to the microdata, containing the input script for SAS, available on official website: |
vars |
Vector of variable names to be kept for analysis. Default is to keep all variables. |
A tibble with selected variables of the microdata, including the necessary survey design ones.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/sociais/trabalho/9171-pesquisa-nacional-por-amostra-de-domicilios-continua-mensal.html?=&t=o-que-e> and consult the other functions of this package, described below.
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
pnadc_labeller for labeling categorical variables from PNADC microdata.
pnadc_deflator for adding deflator variables to PNADC microdata.
pnadc_design for creating PNADC survey design object.
pnadc_example for getting the path of the quarter PNADC toy example files.
input_path <- pnadc_example(path="input_example.txt") data_path <- pnadc_example(path="exampledata.txt") pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002"))
input_path <- pnadc_example(path="input_example.txt") data_path <- pnadc_example(path="exampledata.txt") pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002"))