# Pesquisa Mensal de Emprego (PME)

*Contributed by Dr. Djalma Pessoa <pessoad@gmail.com>*

The Pesquisa Mensal de Emprego (PME) is the monthly labor force survey covering the six largest Brazilian cities.

One table with one row per individual within each sampled household.

A complex sample survey designed to generalize to the civilian population of Brazil’s six largest cities.

Released monthly since March 2002.

Administered by the Instituto Brasileiro de Geografia e Estatistica.

## Simplified Download and Importation

The R `lodown`

package easily downloads and imports all available PME microdata by simply specifying `"pme"`

with an `output_dir =`

parameter in the `lodown()`

function. Depending on your internet connection and computer processing speed, you might prefer to run this step overnight.

```
library(lodown)
lodown( "pme" , output_dir = file.path( path.expand( "~" ) , "PME" ) )
```

`lodown`

also provides a catalog of available microdata extracts with the `get_catalog()`

function. After requesting the PME catalog, you could pass a subsetted catalog through the `lodown()`

function in order to download and import specific extracts (rather than all available extracts).

```
library(lodown)
# examine all available PME microdata files
pme_cat <-
get_catalog( "pme" ,
output_dir = file.path( path.expand( "~" ) , "PME" ) )
# 2016 only
pme_cat <- subset( pme_cat , year == 2016 )
# download the microdata to your local computer
pme_cat <- lodown( "pme" , pme_cat )
```

## Analysis Examples with the `survey`

library

Construct a complex sample survey design:

```
options( survey.lonely.psu = "adjust" )
library(survey)
pme_df <- readRDS( file.path( path.expand( "~" ) , "PME" , "pme 2016 01.rds" ) )
# throw out records missing their cluster variable
pme_df <- subset( pme_df , !is.na( v113 ) )
pop_totals <- unique( pme_df[ , c( 'v035' , 'v114' ) ] )
prestratified_design <-
svydesign(
~ v113 ,
strata = ~ v112 ,
data = pme_df ,
weights = ~ v211 ,
nest = TRUE
)
pme_design <-
postStratify( prestratified_design , ~ v035 , pop_totals )
```

### Variable Recoding

Add new columns to the data set:

```
pme_design <-
update(
pme_design ,
one = 1 ,
# calculate whether each person is at least ten years of age
pia = as.numeric( v234 >= 10 ) ,
# determine individuals who are employed
ocup_c = as.numeric( v401 == 1 | v402 == 1 | v403 == 1 ) ,
sexo = factor( v203 , labels = c( "male" , "female" ) ) ,
region =
factor(
v035 ,
levels = c( 26 , 29 , 31 , 33 , 35 , 43 ) ,
labels = c( "Recife" , "Salvador" , "Belo Horizonte" ,
"Rio de Janeiro" , "Sao Paulo" , "Porto Alegre" )
)
)
pme_design <-
update(
pme_design ,
# determine individuals who are unemployed
desocup30 = as.numeric( ocup_c == 0 & !is.na( v461 ) & v465 == 1 )
)
pme_design <-
update(
pme_design ,
# determine individuals who are either working or not working
pea_c = as.numeric( ocup_c == 1 | desocup30 == 1 )
)
```

### Unweighted Counts

Count the unweighted number of records in the survey sample, overall and by groups:

```
sum( weights( pme_design , "sampling" ) != 0 )
svyby( ~ one , ~ region , pme_design , unwtd.count )
```

### Weighted Counts

Count the weighted size of the generalizable population, overall and by groups:

```
svytotal( ~ one , pme_design )
svyby( ~ one , ~ region , pme_design , svytotal )
```

### Descriptive Statistics

Calculate the mean (average) of a linear variable, overall and by groups:

```
svymean( ~ vd25 , pme_design , na.rm = TRUE )
svyby( ~ vd25 , ~ region , pme_design , svymean , na.rm = TRUE )
```

Calculate the distribution of a categorical variable, overall and by groups:

```
svymean( ~ sexo , pme_design )
svyby( ~ sexo , ~ region , pme_design , svymean )
```

Calculate the sum of a linear variable, overall and by groups:

```
svytotal( ~ vd25 , pme_design , na.rm = TRUE )
svyby( ~ vd25 , ~ region , pme_design , svytotal , na.rm = TRUE )
```

Calculate the weighted sum of a categorical variable, overall and by groups:

```
svytotal( ~ sexo , pme_design )
svyby( ~ sexo , ~ region , pme_design , svytotal )
```

Calculate the median (50th percentile) of a linear variable, overall and by groups:

```
svyquantile( ~ vd25 , pme_design , 0.5 , na.rm = TRUE )
svyby(
~ vd25 ,
~ region ,
pme_design ,
svyquantile ,
0.5 ,
ci = TRUE ,
keep.var = TRUE ,
na.rm = TRUE
)
```

Estimate a ratio:

```
svyratio(
numerator = ~ desocup30 ,
denominator = ~ pea_c ,
pme_design ,
na.rm = TRUE
)
```

### Subsetting

Restrict the survey design to teenagers:

`sub_pme_design <- subset( pme_design , v234 %in% 13:19 )`

Calculate the mean (average) of this subset:

`svymean( ~ vd25 , sub_pme_design , na.rm = TRUE )`

### Measures of Uncertainty

Extract the coefficient, standard error, confidence interval, and coefficient of variation from any descriptive statistics function result, overall and by groups:

```
this_result <- svymean( ~ vd25 , pme_design , na.rm = TRUE )
coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )
grouped_result <-
svyby(
~ vd25 ,
~ region ,
pme_design ,
svymean ,
na.rm = TRUE
)
coef( grouped_result )
SE( grouped_result )
confint( grouped_result )
cv( grouped_result )
```

Calculate the degrees of freedom of any survey design object:

`degf( pme_design )`

Calculate the complex sample survey-adjusted variance of any statistic:

`svyvar( ~ vd25 , pme_design , na.rm = TRUE )`

Include the complex sample design effect in the result for a specific statistic:

```
# SRS without replacement
svymean( ~ vd25 , pme_design , na.rm = TRUE , deff = TRUE )
# SRS with replacement
svymean( ~ vd25 , pme_design , na.rm = TRUE , deff = "replace" )
```

Compute confidence intervals for proportions using methods that may be more accurate near 0 and 1. See `?svyciprop`

for alternatives:

```
svyciprop( ~ ocup_c , pme_design ,
method = "likelihood" , na.rm = TRUE )
```

### Regression Models and Tests of Association

Perform a design-based t-test:

`svyttest( vd25 ~ ocup_c , pme_design )`

Perform a chi-squared test of association for survey data:

```
svychisq(
~ ocup_c + sexo ,
pme_design
)
```

Perform a survey-weighted generalized linear model:

```
glm_result <-
svyglm(
vd25 ~ ocup_c + sexo ,
pme_design
)
summary( glm_result )
```

## Analysis Examples with `srvyr`

The R `srvyr`

library calculates summary statistics from survey data, such as the mean, total or quantile using dplyr-like syntax. srvyr allows for the use of many verbs, such as `summarize`

, `group_by`

, and `mutate`

, the convenience of pipe-able functions, the `tidyverse`

style of non-standard evaluation and more consistent return types than the `survey`

package. This vignette details the available features. As a starting point for PME users, this code replicates previously-presented examples:

```
library(srvyr)
pme_srvyr_design <- as_survey( pme_design )
```

Calculate the mean (average) of a linear variable, overall and by groups:

```
pme_srvyr_design %>%
summarize( mean = survey_mean( vd25 , na.rm = TRUE ) )
pme_srvyr_design %>%
group_by( region ) %>%
summarize( mean = survey_mean( vd25 , na.rm = TRUE ) )
```