-
Notifications
You must be signed in to change notification settings - Fork 449
/
vacs.Rmd
375 lines (261 loc) · 11.8 KB
/
vacs.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
# Violence Against Children And Youth Surveys (VACS) {-}
[![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 global surveillance system to track and monitor the burden of violence against children.
* One table per country with one row per sampled respondent.
* Nationally representative cross-sectional household surveys of children and youth ages 13–24.
* No listed update frequency across the participating nations.
* Led by the [CDC](https://www.cdc.gov/) through funding from [PEPFAR](https://www.state.gov/pepfar/), in partnership with [Together for Girls](https://www.togetherforgirls.org/en/partners).
---
## Recommended Reading {-}
Four Example Strengths & Limitations:
✔️ [Split sample interviews male and female participants in different communities to eliminate risk of harm](https://www.cdc.gov/violence-against-children/php/country-process/index.html)
✔️ [Some PEPFAR recipient nations coordinate voluntary HIV testing with face-to-face interviews](https://doi.org/10.1542/peds.2022-057124)
❌ [Must balance standardization of procedures and protocols and adaptation for culture and context](https://www.cdc.gov/violence-against-children/media/pdfs/VACS-trainingwhitepaper.pdf)
❌ [Certain sampled households excluded due to cyclones or armed attacks carried out by terrorists](https://www.togetherforgirls.org/en/resources/mozambique-vacs-report-2022)
<br>
Three Example Findings:
1. [Kenya observed significant declines in the prevalence of lifetime violence and some risk factors for violence and HIV, and improvements in some service seeking indicators between 2010 and 2019](https://doi.org/10.1016/S2214-109X(21)00457-5).
2. [In 2015, 49% of 13-24 year old Ugandan females reported any lifetime history of sexual violence](https://doi.org/10.1371/journal.pone.0260986).
3. [Over 2015-2016, 22% of Rwandan males age 13-17 reported physical violence in the past year](https://doi.org/10.1186/s12889-022-14815-0).
<br>
Two Methodology Documents:
> [Sampling design and methodology of the Violence Against Children and Youth Surveys](https://www.ncbi.nlm.nih.gov/pubmed/30472679)
> [Violence Against Children Surveys (VACS): Towards a global surveillance system](http://injuryprevention.bmj.com/content/22/Suppl_1/i17.long)
<br>
One Haiku:
```{r}
# enable us to
# lodge cane between each spoke of
# cycles of abuse
```
---
## Download, Import, Preparation {-}
1. Request public VACS data at https://www.togetherforgirls.org/en/analyzing-public-vacs-data.
2. Select the Mozambique 2019 dataset and Stata option.
3. Download and unzip the `Mozambique VACS Public Use Dataset` files:
```{r eval = FALSE , results = "hide" }
library(haven)
vacs_tbl <- read_stata( file.path( path.expand( "~" ) , "mozambique_public use data.dta" ) )
vacs_df <- data.frame( vacs_tbl )
names( vacs_df ) <- tolower( names( vacs_df ) )
```
### Save Locally \ {-}
Save the object at any point:
```{r eval = FALSE , results = "hide" }
# vacs_fn <- file.path( path.expand( "~" ) , "VACS" , "this_file.rds" )
# saveRDS( vacs_df , file = vacs_fn , compress = FALSE )
```
Load the same object:
```{r eval = FALSE , results = "hide" }
# vacs_df <- readRDS( vacs_fn )
```
### Survey Design Definition {-}
Construct a complex sample survey design:
```{r eval = FALSE , results = "hide" }
library(survey)
options( survey.lonely.psu = "adjust" )
vacs_design <-
svydesign(
ids = ~cluster ,
strata = ~strata ,
weights = ~sampleweight ,
data = subset( vacs_df , sampleweight > 0 ) ,
nest = TRUE
)
```
### Variable Recoding {-}
Add new columns to the data set:
```{r eval = FALSE , results = "hide" }
vacs_design <-
update(
vacs_design ,
one = 1 ,
age_sex_group =
factor(
ifelse( agegrp == 1 , sex , sex + 2 ) ,
levels = 1:4 ,
labels = c( 'male 13-17' , 'female 13-17' , 'male 18-24' , 'female 18-24' )
) ,
sex = factor( sex , levels = 1:2 , labels = c( 'male' , 'female' ) ) ,
agegrp = factor( agegrp , levels = 1:2 , labels = c( '13-17' , '18-24' ) ) ,
ever_attended_school = ifelse( eversch %in% 1:2 , as.numeric( eversch == 1 ) , NA ) ,
childhood_physical_violence = as.numeric( pv18 == 1 ) ,
marry =
factor(
marry ,
levels = 1:3 ,
labels =
c( 'Yes, ever married' , 'Yes, ever lived with a partner' ,
'No, never married or lived with a partner' )
) ,
age_at_first_pregnancy = ifelse( prage < 98 , prage , NA ) ,
age_at_first_cohabitation = ifelse( marage < 98 , marage , NA )
)
```
---
## 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( vacs_design , "sampling" ) != 0 )
svyby( ~ one , ~ age_sex_group , vacs_design , unwtd.count )
```
### Weighted Counts {-}
Count the weighted size of the generalizable population, overall and by groups:
```{r eval = FALSE , results = "hide" }
svytotal( ~ one , vacs_design )
svyby( ~ one , ~ age_sex_group , vacs_design , svytotal )
```
### Descriptive Statistics {-}
Calculate the mean (average) of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svymean( ~ age_at_first_cohabitation , vacs_design , na.rm = TRUE )
svyby( ~ age_at_first_cohabitation , ~ age_sex_group , vacs_design , svymean , na.rm = TRUE )
```
Calculate the distribution of a categorical variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svymean( ~ marry , vacs_design )
svyby( ~ marry , ~ age_sex_group , vacs_design , svymean )
```
Calculate the sum of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svytotal( ~ age_at_first_cohabitation , vacs_design , na.rm = TRUE )
svyby( ~ age_at_first_cohabitation , ~ age_sex_group , vacs_design , svytotal , na.rm = TRUE )
```
Calculate the weighted sum of a categorical variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svytotal( ~ marry , vacs_design )
svyby( ~ marry , ~ age_sex_group , vacs_design , svytotal )
```
Calculate the median (50th percentile) of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
svyquantile( ~ age_at_first_cohabitation , vacs_design , 0.5 , na.rm = TRUE )
svyby(
~ age_at_first_cohabitation ,
~ age_sex_group ,
vacs_design ,
svyquantile ,
0.5 ,
ci = TRUE , na.rm = TRUE
)
```
Estimate a ratio:
```{r eval = FALSE , results = "hide" }
svyratio(
numerator = ~ age_at_first_pregnancy ,
denominator = ~ age_at_first_cohabitation ,
vacs_design ,
na.rm = TRUE
)
```
### Subsetting {-}
Restrict the survey design to :
```{r eval = FALSE , results = "hide" }
sub_vacs_design <- subset( vacs_design , childhood_physical_violence == 1 )
```
Calculate the mean (average) of this subset:
```{r eval = FALSE , results = "hide" }
svymean( ~ age_at_first_cohabitation , sub_vacs_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( ~ age_at_first_cohabitation , vacs_design , na.rm = TRUE )
coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )
grouped_result <-
svyby(
~ age_at_first_cohabitation ,
~ age_sex_group ,
vacs_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( vacs_design )
```
Calculate the complex sample survey-adjusted variance of any statistic:
```{r eval = FALSE , results = "hide" }
svyvar( ~ age_at_first_cohabitation , vacs_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( ~ age_at_first_cohabitation , vacs_design , na.rm = TRUE , deff = TRUE )
# SRS with replacement
svymean( ~ age_at_first_cohabitation , vacs_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( ~ ever_attended_school , vacs_design ,
method = "likelihood" , na.rm = TRUE )
```
### Regression Models and Tests of Association {-}
Perform a design-based t-test:
```{r eval = FALSE , results = "hide" }
svyttest( age_at_first_cohabitation ~ ever_attended_school , vacs_design )
```
Perform a chi-squared test of association for survey data:
```{r eval = FALSE , results = "hide" }
svychisq(
~ ever_attended_school + marry ,
vacs_design
)
```
Perform a survey-weighted generalized linear model:
```{r eval = FALSE , results = "hide" }
glm_result <-
svyglm(
age_at_first_cohabitation ~ ever_attended_school + marry ,
vacs_design
)
summary( glm_result )
```
---
## Replication Example {-}
This example matches statistics and confidence intervals within 0.1% from the Final Report of the [Mozambique Violence Against Children and Youth Survey (VACS), 2019](https://files.mutualcdn.com/tfg/assets/files/Mozambique-VACS-report.pdf), `Table 4.1.1. Prevalence of different types of sexual violence[1] before age 18, among 18-24-year-olds`:
```{r eval = FALSE , results = "hide" }
females_18_to_24_design <- subset( vacs_design , sex == 'female' & agegrp == '18-24' )
# define a function to check unweighted N, prevalence, confidence interval for each estimate
check_sv <-
function( this_variable , this_design = females_18_to_24_design , N , prevalence , lb , ub ){
this_formula <- as.formula( paste( "~ as.numeric(" , this_variable , "== 1 )" ) )
stopifnot( coef( unwtd.count( this_formula , this_design ) ) == N )
this_result <- svymean( this_formula , this_design , na.rm = TRUE )
stopifnot( round( coef( this_result ) , 3 ) == prevalence )
stopifnot( abs( confint( this_result )[1] - lb ) < 0.0015 )
stopifnot( abs( confint( this_result )[2] - ub ) < 0.0015 )
invisible( TRUE )
}
# sexual touching in childhood
check_sv( "sv1_only18" , N = 1232 , prevalence = 0.066 , lb = 0.039 , ub = 0.093 )
# unwanted attempted sex in childhood
check_sv( "sv2_only18" , N = 1232 , prevalence = 0.061 , lb = 0.035 , ub = 0.087 )
# pressured or coerced sex in childhood
check_sv( "sv4_only18" , N = 1221 , prevalence = 0.056 , lb = 0.035 , ub = 0.077 )
# physically forced sex in childhood
check_sv( "sv3_only18" , N = 1231 , prevalence = 0.035 , lb = 0.020 , ub = 0.051 )
```
---
## 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 VACS users, this code replicates previously-presented examples:
```{r eval = FALSE , results = "hide" }
library(srvyr)
vacs_srvyr_design <- as_survey( vacs_design )
```
Calculate the mean (average) of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
vacs_srvyr_design %>%
summarize( mean = survey_mean( age_at_first_cohabitation , na.rm = TRUE ) )
vacs_srvyr_design %>%
group_by( age_sex_group ) %>%
summarize( mean = survey_mean( age_at_first_cohabitation , na.rm = TRUE ) )
```