# National Survey of Children’s Health (NSCH)

*Contributed by Emily Wiegand <erowewiegand@gmail.com>*

The National Survey of Children’s Health (NSCH) offers state-level estimates of children’s health care and the family environment.

One row per sampled child under eighteen.

A complex sample survey designed to generalize to non-institutionalized children in the United States at the state-level.

Released every four or five years since 2003.

Sponsored by the Maternal and Child Health Bureau of the Health Resources and Services Administration.

## Simplified Download and Importation

The R `lodown`

package easily downloads and imports all available NSCH microdata by simply specifying `"nsch"`

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( "nsch" , output_dir = file.path( path.expand( "~" ) , "NSCH" ) )
```

`lodown`

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

function. After requesting the NSCH 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 NSCH microdata files
nsch_cat <-
get_catalog( "nsch" ,
output_dir = file.path( path.expand( "~" ) , "NSCH" ) )
# 2012 only
nsch_cat <- subset( nsch_cat , year == 2012 )
# download the microdata to your local computer
nsch_cat <- lodown( "nsch" , nsch_cat )
```

## Analysis Examples with the `survey`

library

Construct a multiply-imputed, complex sample survey design:

```
library(survey)
library(mitools)
nsch_imp <- readRDS( file.path( path.expand( "~" ) , "NSCH" , "2012 main.rds" ) )
nsch_design <-
svydesign(
id = ~ 1 ,
strata = ~ state + sample ,
weights = ~ nschwt ,
data = imputationList( nsch_imp )
)
```

### Variable Recoding

Add new columns to the data set:

```
nsch_design <-
update(
nsch_design ,
indicator_1_3 = ifelse( k6q40 > 1 , NA , k6q40 ) ,
indicator_5_2 =
ifelse( k7q05r %in% 1:5 , 1 ,
ifelse( k7q05r %in% 0 , 0 , NA ) ) ,
indicator_5_3 =
ifelse( k7q30 == 1 | k7q31 == 1 | k7q32 == 1 , 1 ,
ifelse( k7q30 == 0 | k7q31 == 0 | k7q32 == 0 , 0 , NA ) ) ,
povcat =
factor(
findInterval( povlevel_i , c( 1 , 2 , 6 , 8 ) ) ,
labels =
c( "below poverty" , "100-199% fpl" , "200-399% fpl" , "400%+ fpl" )
) ,
sex = factor( ifelse( sex %in% 1:2 , sex , NA ) , labels = c( "male" , "female" ) )
)
```

### Unweighted Counts

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

```
MIcombine( with( nsch_design , svyby( ~ one , ~ one , unwtd.count ) ) )
MIcombine( with( nsch_design , svyby( ~ one , ~ state , unwtd.count ) ) )
```

### Weighted Counts

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

```
MIcombine( with( nsch_design , svytotal( ~ one ) ) )
MIcombine( with( nsch_design ,
svyby( ~ one , ~ state , svytotal )
) )
```

### Descriptive Statistics

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

```
MIcombine( with( nsch_design , svymean( ~ ageyr_child ) ) )
MIcombine( with( nsch_design ,
svyby( ~ ageyr_child , ~ state , svymean )
) )
```

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

```
MIcombine( with( nsch_design , svymean( ~ povcat ) ) )
MIcombine( with( nsch_design ,
svyby( ~ povcat , ~ state , svymean )
) )
```

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

```
MIcombine( with( nsch_design , svytotal( ~ ageyr_child ) ) )
MIcombine( with( nsch_design ,
svyby( ~ ageyr_child , ~ state , svytotal )
) )
```

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

```
MIcombine( with( nsch_design , svytotal( ~ povcat ) ) )
MIcombine( with( nsch_design ,
svyby( ~ povcat , ~ state , svytotal )
) )
```

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

```
MIcombine( with( nsch_design ,
svyquantile(
~ ageyr_child ,
0.5 , se = TRUE
) ) )
MIcombine( with( nsch_design ,
svyby(
~ ageyr_child , ~ state , svyquantile ,
0.5 , se = TRUE ,
keep.var = TRUE , ci = TRUE
) ) )
```

Estimate a ratio:

```
MIcombine( with( nsch_design ,
svyratio( numerator = ~ k6q63 , denominator = ~ totkids4 )
) )
```

### Subsetting

Restrict the survey design to only children:

`sub_nsch_design <- subset( nsch_design , agepos4 == 1 )`

Calculate the mean (average) of this subset:

`MIcombine( with( sub_nsch_design , svymean( ~ ageyr_child ) ) )`

### 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 <-
MIcombine( with( nsch_design ,
svymean( ~ ageyr_child )
) )
coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )
grouped_result <-
MIcombine( with( nsch_design ,
svyby( ~ ageyr_child , ~ state , svymean )
) )
coef( grouped_result )
SE( grouped_result )
confint( grouped_result )
cv( grouped_result )
```

Calculate the degrees of freedom of any survey design object:

`degf( nsch_design$designs[[1]] )`

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

`MIcombine( with( nsch_design , svyvar( ~ ageyr_child ) ) )`

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

```
# SRS without replacement
MIcombine( with( nsch_design ,
svymean( ~ ageyr_child , deff = TRUE )
) )
# SRS with replacement
MIcombine( with( nsch_design ,
svymean( ~ ageyr_child , deff = "replace" )
) )
```

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

for alternatives:

```
MIsvyciprop( ~ indicator_5_2 , nsch_design ,
method = "likelihood" )
```

### Regression Models and Tests of Association

Perform a design-based t-test:

`MIsvyttest( ageyr_child ~ indicator_5_2 , nsch_design )`

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

`MIsvychisq( ~ indicator_5_2 + povcat , nsch_design )`

Perform a survey-weighted generalized linear model:

```
glm_result <-
MIcombine( with( nsch_design ,
svyglm( ageyr_child ~ indicator_5_2 + povcat )
) )
summary( glm_result )
```