-
Notifications
You must be signed in to change notification settings - Fork 449
/
nsch.Rmd
438 lines (316 loc) · 13 KB
/
nsch.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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# National Survey of Children's Health (NSCH) {-}
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) <a href="https://github.com/asdfree/nsch/actions"><img src="https://github.com/asdfree/nsch/actions/workflows/r.yml/badge.svg" alt="Github Actions Badge"></a>
Estimates of children's health care and family environments to inform reports like [Healthy People 2030](https://www.healthypeople.gov/).
* One screener table with one row per eligible child (1+ rows per household), one topical table with the sampled child (only one row per household) from three stacked age-specific questionnaires.
* A complex sample survey designed to generalize to non-institutionalized U.S. children under 18.
* Released every four or five years since 2003, annually since 2016.
* Sponsored by the [Maternal and Child Health Bureau, Health Resources and Services Administration](http://www.mchb.hrsa.gov/).
---
## Recommended Reading {-}
Four Example Strengths & Limitations:
✔️ [Detailed information about child and family health measures](https://www.childhealthdata.org/docs/default-source/nsch-docs/2023-nsch-content-map_child-and-family-health-measures_cahmi.pdf)
✔️ [The redesigned 2016 NSCH converted to an annual survey](https://pmc.ncbi.nlm.nih.gov/articles/PMC6372340/#S13)
❌ [The redesigned 2016 NSCH broke trend with earlier surveys](https://www.childhealthdata.org/learn-about-the-nsch/survey-revisions)
❌ [Longitudinal rather than cross-sectional data may be more accurate at assessing childhood trends](https://doi.org/10.3390/pediatric16040084)
<br>
Three Example Findings:
1. [Across 2016-2022, nonsupine sleep averaged 12%, 13%, 19%, and 23% at months 4, 6, 9, and 12](http://doi.org/10.1001/jamanetworkopen.2024.50277).
2. [A minimum wage increase through childhood is associated with significant child health improvement](http://doi.org/10.3386/w26691).
3. [Publicly insured kids in 2018 were more likely to have dental sealants in the past year than others](http://doi.org/10.22514/jocpd.2024.138).
<br>
Two Methodology Documents:
> [2022 National Survey of Children's Health Methodology Report](https://www2.census.gov/programs-surveys/nsch/technical-documentation/methodology/2022-NSCH-Methodology-Report.pdf)
> [2022 National Survey of Children's Health Data Users Frequently Asked Questions (FAQs)](https://www2.census.gov/programs-surveys/nsch/technical-documentation/methodology/2022-NSCH-FAQs.pdf)
<br>
One Haiku:
```{r}
# "age but a number"
# lied babe from crib. "your nose grows"
# cried gramps changing bib
```
---
## Function Definitions {-}
Define a function to download, unzip, and import each comma-separated value file:
```{r eval = FALSE , results = "hide" }
library(haven)
nsch_stata_import <-
function( this_url ){
this_tf <- tempfile()
download.file( this_url , this_tf , mode = 'wb' )
unzipped_files <- unzip( this_tf , exdir = tempdir() )
this_stata <- grep( '\\.dta$' , unzipped_files , value = TRUE )
this_tbl <- read_stata( this_stata )
this_df <- data.frame( this_tbl )
file.remove( c( this_tf , unzipped_files ) )
names( this_df ) <- tolower( names( this_df ) )
this_df
}
```
---
## Download, Import, Preparation {-}
Download and import the sample adult interview and imputed income files:
```{r eval = FALSE , results = "hide" }
nsch_screener_url <-
"https://www2.census.gov/programs-surveys/nsch/datasets/2022/nsch_2022_screener_Stata.zip"
nsch_topical_url <-
"https://www2.census.gov/programs-surveys/nsch/datasets/2022/nsch_2022_topical_Stata.zip"
nsch_screener_df <- nsch_stata_import( nsch_screener_url )
nsch_df <- nsch_stata_import( nsch_topical_url )
```
### Save Locally \ {-}
Save the object at any point:
```{r eval = FALSE , results = "hide" }
# nsch_fn <- file.path( path.expand( "~" ) , "NSCH" , "this_file.rds" )
# saveRDS( nsch_df , file = nsch_fn , compress = FALSE )
```
Load the same object:
```{r eval = FALSE , results = "hide" }
# nsch_df <- readRDS( nsch_fn )
```
### Survey Design Definition {-}
Construct a multiply-imputed, complex sample survey design:
Remove the fpl columns from the main data.frame:
```{r eval = FALSE , results = "hide" }
fpl_columns <- grep( '^fpl_i[0-9]' , names( nsch_df ) , value = TRUE )
fpl_wide_df <- nsch_df[ c( 'hhid' , fpl_columns ) ]
nsch_df[ fpl_columns ] <- NULL
```
Reshape the fpl columns from wide to long:
```{r eval = FALSE , results = "hide" }
fpl_long_df <-
reshape(
fpl_wide_df ,
varying = list( fpl_columns ) ,
direction = 'long' ,
timevar = 'implicate' ,
idvar = 'hhid'
)
names( fpl_long_df )[ ncol( fpl_long_df ) ] <- 'fpl'
```
Merge the fpl table with multiple records per child onto the main table:
```{r eval = FALSE , results = "hide" }
nsch_long_df <- merge( nsch_df , fpl_long_df )
stopifnot( nrow( nsch_long_df ) == nrow( fpl_long_df ) )
stopifnot( nrow( nsch_long_df ) / length( fpl_columns ) == nrow( nsch_df ) )
```
Reshape the imputed income data.frame into a list based on the implicate number:
```{r eval = FALSE , results = "hide" }
nsch_list <- split( nsch_long_df , nsch_long_df[ , 'implicate' ] )
```
Define the design:
```{r eval = FALSE , results = "hide" }
library(survey)
library(mitools)
nsch_design <-
svydesign(
id = ~ 1 ,
strata = ~ fipsst + stratum ,
weights = ~ fwc ,
data = imputationList( nsch_list ) ,
nest = TRUE
)
```
### Variable Recoding {-}
Add new columns to the data set:
```{r eval = FALSE , results = "hide" }
nsch_design <-
update(
nsch_design ,
one = 1 ,
state_name =
factor(
fipsst ,
levels =
c(1L, 2L, 4L, 5L, 6L, 8L, 9L, 10L,
11L, 12L, 13L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L,
26L, 27L, 28L, 29L, 30L, 31L, 32L,
33L, 34L, 35L, 36L, 37L, 38L, 39L,
40L, 41L, 42L, 44L, 45L, 46L, 47L,
48L, 49L, 50L, 51L, 53L, 54L, 55L,
56L) ,
labels =
c("Alabama", "Alaska", "Arizona", "Arkansas", "California",
"Colorado", "Connecticut", "Delaware", "District of Columbia",
"Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana",
"Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland",
"Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri",
"Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey",
"New Mexico", "New York", "North Carolina", "North Dakota", "Ohio",
"Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina",
"South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia",
"Washington", "West Virginia", "Wisconsin", "Wyoming")
) ,
overall_health =
factor(
c( 1 , 1 , 2 , 3 , 3 )[ k2q01 ] ,
levels = 1:3 ,
labels = c( 'excellent or very good' , 'good' , 'fair or poor' )
) ,
poverty_categories =
factor(
1 + findInterval( fpl , c( 100 , 200 , 400 ) ) ,
labels =
c( "below poverty" , "100-199% fpl" , "200-399% fpl" , "400%+ fpl" )
) ,
under_six_ever_breastfed =
as.numeric( k6q40 == 1 ) ,
sc_sex =
factor( ifelse( sc_sex %in% 1:2 , sc_sex , NA ) , labels = c( "male" , "female" ) )
)
```
---
## 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" }
MIcombine( with( nsch_design , svyby( ~ one , ~ one , unwtd.count ) ) )
MIcombine( with( nsch_design , svyby( ~ one , ~ state_name , unwtd.count ) ) )
```
### Weighted Counts {-}
Count the weighted size of the generalizable population, overall and by groups:
```{r eval = FALSE , results = "hide" }
MIcombine( with( nsch_design , svytotal( ~ one ) ) )
MIcombine( with( nsch_design ,
svyby( ~ one , ~ state_name , svytotal )
) )
```
### Descriptive Statistics {-}
Calculate the mean (average) of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
MIcombine( with( nsch_design , svymean( ~ sc_age_years ) ) )
MIcombine( with( nsch_design ,
svyby( ~ sc_age_years , ~ state_name , svymean )
) )
```
Calculate the distribution of a categorical variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
MIcombine( with( nsch_design , svymean( ~ poverty_categories ) ) )
MIcombine( with( nsch_design ,
svyby( ~ poverty_categories , ~ state_name , svymean )
) )
```
Calculate the sum of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
MIcombine( with( nsch_design , svytotal( ~ sc_age_years ) ) )
MIcombine( with( nsch_design ,
svyby( ~ sc_age_years , ~ state_name , svytotal )
) )
```
Calculate the weighted sum of a categorical variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
MIcombine( with( nsch_design , svytotal( ~ poverty_categories ) ) )
MIcombine( with( nsch_design ,
svyby( ~ poverty_categories , ~ state_name , svytotal )
) )
```
Calculate the median (50th percentile) of a linear variable, overall and by groups:
```{r eval = FALSE , results = "hide" }
MIcombine( with( nsch_design ,
svyquantile(
~ sc_age_years ,
0.5 , se = TRUE
) ) )
MIcombine( with( nsch_design ,
svyby(
~ sc_age_years , ~ state_name , svyquantile ,
0.5 , se = TRUE ,
ci = TRUE
) ) )
```
Estimate a ratio:
```{r eval = FALSE , results = "hide" }
MIcombine( with( nsch_design ,
svyratio( numerator = ~ liveusa_yr , denominator = ~ sc_age_years , na.rm = TRUE )
) )
```
### Subsetting {-}
Restrict the survey design to only children:
```{r eval = FALSE , results = "hide" }
sub_nsch_design <- subset( nsch_design , agepos4 == 1 )
```
Calculate the mean (average) of this subset:
```{r eval = FALSE , results = "hide" }
MIcombine( with( sub_nsch_design , svymean( ~ sc_age_years ) ) )
```
### 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 <-
MIcombine( with( nsch_design ,
svymean( ~ sc_age_years )
) )
coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )
grouped_result <-
MIcombine( with( nsch_design ,
svyby( ~ sc_age_years , ~ state_name , svymean )
) )
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( nsch_design$designs[[1]] )
```
Calculate the complex sample survey-adjusted variance of any statistic:
```{r eval = FALSE , results = "hide" }
MIcombine( with( nsch_design , svyvar( ~ sc_age_years ) ) )
```
Include the complex sample design effect in the result for a specific statistic:
```{r eval = FALSE , results = "hide" }
# SRS without replacement
MIcombine( with( nsch_design ,
svymean( ~ sc_age_years , deff = TRUE )
) )
# SRS with replacement
MIcombine( with( nsch_design ,
svymean( ~ sc_age_years , 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" }
# MIsvyciprop( ~ under_six_ever_breastfed , nsch_design ,
# method = "likelihood" )
```
### Regression Models and Tests of Association {-}
Perform a design-based t-test:
```{r eval = FALSE , results = "hide" }
# MIsvyttest( sc_age_years ~ under_six_ever_breastfed , nsch_design )
```
Perform a chi-squared test of association for survey data:
```{r eval = FALSE , results = "hide" }
# MIsvychisq( ~ under_six_ever_breastfed + poverty_categories , nsch_design )
```
Perform a survey-weighted generalized linear model:
```{r eval = FALSE , results = "hide" }
glm_result <-
MIcombine( with( nsch_design ,
svyglm( sc_age_years ~ under_six_ever_breastfed + poverty_categories )
) )
summary( glm_result )
```
---
## Replication Example {-}
**As noted in the bold red footnotes of their published table, this technique is not correct and should not be used. The [technical documents](https://www2.census.gov/programs-surveys/nsch/technical-documentation/methodology/NSCH-Analysis-with-Imputed-Data-Guide.pdf) recommend a method matching the `MIcombine` syntax shown above.** This code matches statistics and confidence intervals within 0.5% from the `Excellent or very good` column of [Indicator 1.1: In general, how would you describe this child's health?](https://www.childhealthdata.org/browse/survey/results?q=10033&r=1&g=1081):
```{r eval = FALSE , results = "hide" }
results <-
svyby(
~ as.numeric( overall_health == 'excellent or very good' ) ,
~ poverty_categories ,
nsch_design$designs[[1]] ,
svymean ,
na.rm = TRUE
)
published_proportions <- c( 0.817 , 0.862 , 0.922 , 0.947 )
published_lb <- c( 0.797 , 0.843 , 0.914 , 0.941 )
published_ub <- c( 0.835 , 0.879 , 0.930 , 0.952 )
stopifnot( all( abs( round( coef( results ) , 3 ) - published_proportions ) < 0.005 ) )
( ci_results <- confint( results ) )
stopifnot( all( abs( ci_results[ , 1 ] - published_lb ) < 0.005 ) )
stopifnot( all( abs( ci_results[ , 2 ] - published_ub ) < 0.005 ) )
```