-
Notifications
You must be signed in to change notification settings - Fork 449
/
naws.Rmd
386 lines (270 loc) · 13.1 KB
/
naws.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# National Agricultural Workers Survey (NAWS) {-}
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) <img src='https://img.shields.io/badge/Tested%20Locally-Windows%20Laptop-brightgreen' alt='Local Testing Badge'>
The primary face-to-face interview of currently-employed crop workers in the United States, with detailed questions on demographics, occupational injury, health surveillance, and seasonal and migrant labor.
* One cumulative table containing all interviews since 1989, with one row per sampled respondent.
* A complex sample designed to generalize to crop production workers employed by establishments engaged in Crop Production (NAICS 111) and Support Activities for Crop Production (NAICS 1151).
* Released biennially since 1989.
* Administered by the [Employment and Training Administration](https://www.dol.gov/agencies/eta), in partnership with [JBS International](https://www.jbsinternational.com/).
---
## Recommended Reading {-}
Four Example Strengths & Limitations:
✔️ [Employer-based sample increases the likelihood migrant workers will be interviewed](https://naws.jbsinternational.com/about-naws)
✔️ [Seasonal sampling in order to avoid bias](https://www.dol.gov/sites/dolgov/files/ETA/naws/pdfs/NAWS_Justification.pdf)
❌ [Respondents not followed over time](https://globalmigration.ucdavis.edu/sites/g/files/dgvnsk821/files/inline-files/perloff.pdf#page=10)
❌ [Except for California, the data are not available at the state level](https://www.dol.gov/agencies/eta/national-agricultural-workers-survey/overview/data-limitations/)
<br>
Three Example Findings:
1. [Across 2019-2020, 49% of US crop workers said their most recent health care visit for preventive or routine care was to a community health center or migrant health clinic](https://www.dol.gov/sites/dolgov/files/ETA/naws/pdfs/NAWS%20Research%20Brief%201.pdf).
2. [Pesticide exposure increased between 2002 and 2016 among US crop workers](https://pmc.ncbi.nlm.nih.gov/articles/PMC10398559/).
3. [Hired crop workers who responded negatively to "employer provides clean drinking water and disposable cups every day" were at greater odds of injury between 2002 and 2015](https://pmc.ncbi.nlm.nih.gov/articles/PMC10961608/).
<br>
Two Methodology Documents:
> [Findings from the National Agricultural Workers Survey (NAWS) 2021–2022: A Demographic and Employment Profile of United States Crop Workers](https://www.dol.gov/sites/dolgov/files/ETA/naws/pdfs/NAWS%20Research%20Report%2017.pdf)
> [Statistical Methods of the National Agricultural Workers Survey](https://www.dol.gov/sites/dolgov/files/ETA/naws/pdfs/NAWS_Statistical_Methods_AKA_Supporting_Statement_Part_B.pdf)
<br>
One Haiku:
```{r}
# were i king, my court:
# arcimboldo's vertumnus
# jester juggling self
```
---
## Download, Import, Preparation {-}
The [public access dataset](https://www.dol.gov/agencies/eta/national-agricultural-workers-survey/data/files-sas) does not currently include [the variables needed](https://www.dol.gov/sites/dolgov/files/ETA/naws/pdfs/NAWS_Statistical_Methods_AKA_Supporting_Statement_Part_B.pdf#page=19) to get design-adjusted estimates. Previous data releases contained [replicate weights](https://www.dol.gov/sites/dolgov/files/ETA/naws/pdfs/Intro_Analyzing_NAWSPAD.pdf#page=24); however, those have been discontinued.
Although the PUF allows external researchers to match weighted shares, the [UCLA Statistical Consulting Group](https://stats.oarc.ucla.edu/r/seminars/survey-data-analysis-with-r/) cautions _ignoring the clustering will likely lead to standard errors that are underestimated, possibly leading to results that seem to be statistically significant, when in fact, they are not._
In order for the Employment and Training Administration (ETA) to consider a request for offsite use of the restricted NAWS data file, send these items to the contact [listed here for inquiries about the survey](https://www.dol.gov/agencies/eta/national-agricultural-workers-survey/contact):
1. A brief description of the research aims and how NAWS data will support the research;
2. A statement as to why the NAWS public data file is insufficient to meet the research aims;
3. A description of how and when the resulting findings will be disseminated; and
4. A brief description of the analysis plan, so that NAWS staff may assess the suitability of the NAWS given the research aims and analysis plan.
Upon receipt of this microdata, begin by loading the SAS file:
```{r eval = FALSE , results = "hide" }
library(haven)
naws_tbl <-
read_sas(
file.path(
path.expand( "~" ) ,
"nawscrtdvars2db22.sas7bdat"
)
)
naws_df <- data.frame( naws_tbl )
names( naws_df ) <- tolower( names( naws_df ) )
```
### Save Locally \ {-}
Save the object at any point:
```{r eval = FALSE , results = "hide" }
# naws_fn <- file.path( path.expand( "~" ) , "NAWS" , "this_file.rds" )
# saveRDS( naws_df , file = naws_fn , compress = FALSE )
```
Load the same object:
```{r eval = FALSE , results = "hide" }
# naws_df <- readRDS( naws_fn )
```
### Survey Design Definition {-}
Construct a complex sample survey design:
```{r eval = FALSE , results = "hide" }
library(survey)
options( survey.lonely.psu = "adjust" )
naws_design <-
svydesign(
id = ~ cluster ,
strata = ~ interaction( fpc_region , cycle ) ,
data = naws_df ,
weights = ~ pwtycrd,
nest = TRUE
)
```
### Variable Recoding {-}
Add new columns to the data set:
```{r eval = FALSE , results = "hide" }
naws_design <-
update(
naws_design ,
one = 1 ,
country_of_birth =
factor(
findInterval( a07 , c( 3 , 4 , 5 , 100 ) ) ,
levels = 0:4 ,
labels =
c( 'us or pr' , 'mexico' , 'central america' ,
'south america, carribean, asia, or other' , 'missing' )
) ,
gender =
factor(
gender ,
levels = 0:1 ,
labels = c( 'male' , 'female' )
) ,
interview_cohort =
factor(
findInterval( fy , seq( 1989 , 2021 , 2 ) ) ,
levels = seq_along( seq( 1989 , 2021 , 2 ) ) ,
labels = paste( seq( 1989 , 2021 , 2 ) , seq( 1990 , 2022 , 2 ) , sep = '-' )
) ,
authorized_to_work =
ifelse( l01 < 9 , as.numeric( l01 < 5 ) , NA ) ,
hours_worked_last_week_at_farm_job = d04
)
```
---
## Analysis Examples with the `survey` library \ {-}
### Unweighted Counts {-}
Count the unweighted number of records in the survey sample, overall and by groups:
```{r eval = FALSE , results = "hide" }
sum( weights( naws_design , "sampling" ) != 0 )
svyby( ~ one , ~ interview_cohort , naws_design , unwtd.count )
```
### Weighted Counts {-}
Count the weighted size of the generalizable population, overall and by groups:
```{r eval = FALSE , results = "hide" }
svytotal( ~ one , naws_design )
svyby( ~ one , ~ interview_cohort , naws_design , svytotal )
```
### Descriptive Statistics {-}
Calculate the mean (average) of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svymean( ~ waget1 , naws_design , na.rm = TRUE )
svyby( ~ waget1 , ~ interview_cohort , naws_design , svymean , na.rm = TRUE )
```
Calculate the distribution of a categorical variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svymean( ~ country_of_birth , naws_design , na.rm = TRUE )
svyby( ~ country_of_birth , ~ interview_cohort , naws_design , svymean , na.rm = TRUE )
```
Calculate the sum of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svytotal( ~ waget1 , naws_design , na.rm = TRUE )
svyby( ~ waget1 , ~ interview_cohort , naws_design , svytotal , na.rm = TRUE )
```
Calculate the weighted sum of a categorical variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svytotal( ~ country_of_birth , naws_design , na.rm = TRUE )
svyby( ~ country_of_birth , ~ interview_cohort , naws_design , svytotal , na.rm = TRUE )
```
Calculate the median (50th percentile) of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svyquantile( ~ waget1 , naws_design , 0.5 , na.rm = TRUE )
svyby(
~ waget1 ,
~ interview_cohort ,
naws_design ,
svyquantile ,
0.5 ,
ci = TRUE , na.rm = TRUE
)
```
Estimate a ratio:
```{r eval = FALSE , results = "hide" }
svyratio(
numerator = ~ hours_worked_last_week_at_farm_job ,
denominator = ~ numfempl ,
naws_design ,
na.rm = TRUE
)
```
### Subsetting {-}
Restrict the survey design to California, the only standalone state with adequate sample:
```{r eval = FALSE , results = "hide" }
sub_naws_design <- subset( naws_design , region12 == 'CA' )
```
Calculate the mean (average) of this subset:
```{r eval = FALSE , results = "hide" }
svymean( ~ waget1 , sub_naws_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:
```{r eval = FALSE , results = "hide" }
this_result <- svymean( ~ waget1 , naws_design , na.rm = TRUE )
coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )
grouped_result <-
svyby(
~ waget1 ,
~ interview_cohort ,
naws_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:
```{r eval = FALSE , results = "hide" }
degf( naws_design )
```
Calculate the complex sample survey-adjusted variance of any statistic:
```{r eval = FALSE , results = "hide" }
svyvar( ~ waget1 , naws_design , na.rm = TRUE )
```
Include the complex sample design effect in the result for a specific statistic:
```{r eval = FALSE , results = "hide" }
# SRS without replacement
svymean( ~ waget1 , naws_design , na.rm = TRUE , deff = TRUE )
# SRS with replacement
svymean( ~ waget1 , naws_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:
```{r eval = FALSE , results = "hide" }
svyciprop( ~ authorized_to_work , naws_design ,
method = "likelihood" , na.rm = TRUE )
```
### Regression Models and Tests of Association {-}
Perform a design-based t-test:
```{r eval = FALSE , results = "hide" }
svyttest( waget1 ~ authorized_to_work , naws_design )
```
Perform a chi-squared test of association for survey data:
```{r eval = FALSE , results = "hide" }
svychisq(
~ authorized_to_work + country_of_birth ,
naws_design
)
```
Perform a survey-weighted generalized linear model:
```{r eval = FALSE , results = "hide" }
glm_result <-
svyglm(
waget1 ~ authorized_to_work + country_of_birth ,
naws_design
)
summary( glm_result )
```
---
## Replication Example {-}
This example matches the unweighted counts and weighted percents of the gender rows shown on [PDF page 90 of the most current research report](https://www.dol.gov/sites/dolgov/files/ETA/naws/pdfs/NAWS%20Research%20Report%2017.pdf#page=90); however, the restricted-use dataset does not include information to implement a finite population correction (FPC). Since a FPC always reduces the standard error, omitting it only makes results more conservative. JBS International shared standard errors and coefficients of variation omitting the FPC, this exercise precisely matches those numbers as well:
```{r eval = FALSE , results = "hide" }
# less conservative
options( survey.lonely.psu = "remove" )
published_unweighted_counts <- c( 1823 , 775 )
published_percentages <- c( 0.68 , 0.32 )
unpublished_se <- c( 0.024 , 0.024 )
unpublished_cv <- c( 0.04 , 0.08 )
current_cohort <- subset( naws_design , interview_cohort == '2021-2022' )
( unwtd_n <- svyby( ~ one , ~ gender , current_cohort , unwtd.count ) )
stopifnot( all( coef( unwtd_n ) == published_unweighted_counts ) )
( results <- svymean( ~ gender , current_cohort ) )
stopifnot( all( round( coef( results ) , 2 ) == published_percentages ) )
stopifnot( all( round( SE( results ) , 3 ) == unpublished_se ) )
stopifnot( all( round( cv( results ) , 2 ) == unpublished_cv ) )
# more conservative
options( survey.lonely.psu = "adjust" )
```
---
## Analysis Examples with `srvyr` \ {-}
The R `srvyr` library calculates summary statistics from survey data, such as the mean, total or quantile using [dplyr](https://github.com/tidyverse/dplyr/)-like syntax. [srvyr](https://github.com/gergness/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](https://cran.r-project.org/web/packages/srvyr/vignettes/srvyr-vs-survey.html) details the available features. As a starting point for NAWS users, this code replicates previously-presented examples:
```{r eval = FALSE , results = "hide" }
library(srvyr)
naws_srvyr_design <- as_survey( naws_design )
```
Calculate the mean (average) of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
naws_srvyr_design %>%
summarize( mean = survey_mean( waget1 , na.rm = TRUE ) )
naws_srvyr_design %>%
group_by( interview_cohort ) %>%
summarize( mean = survey_mean( waget1 , na.rm = TRUE ) )
```