National Survey of OAA Participants (NPS)
The National Survey of OAA Participants measures program satisfaction with state agency community services for American seniors.
One table with one row per sampled senior respondent.
A complex sample survey designed to generalize to non-institutionalized beneficiaries of Area Agencies on Aging (AAA) within the United States.
Released annually since 2003.
Administered by the U.S. Administration on Aging.
Simplified Download and Importation
The R lodown
package easily downloads and imports all available NPS microdata by simply specifying "nps"
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( "nps" , output_dir = file.path( path.expand( "~" ) , "NPS" ) )
lodown
also provides a catalog of available microdata extracts with the get_catalog()
function. After requesting the NPS 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 NPS microdata files
nps_cat <-
get_catalog( "nps" ,
output_dir = file.path( path.expand( "~" ) , "NPS" ) )
# 2015 only
nps_cat <- subset( nps_cat , year == 2015 )
# download the microdata to your local computer
nps_cat <- lodown( "nps" , nps_cat )
Analysis Examples with the survey
library
Construct a complex sample survey design:
library(survey)
nps_df <-
readRDS(
file.path( path.expand( "~" ) , "NPS" ,
"2015 transportation.rds" ) )
nps_design <-
svrepdesign(
data = nps_df ,
repweights = "pstotwgt[0-9]" ,
weights = ~ pstotwgt ,
type = "Fay" ,
rho = 0.29986 ,
mse = TRUE
)
Variable Recoding
Add new columns to the data set:
nps_design <-
update(
nps_design ,
age_category =
factor( agec , levels = 2:5 , labels =
c( "60-64" , "65-74" , "75-84" , "85+" ) ) ,
gender = factor( gender , labels = c( "male" , "female" ) ) ,
trip_this_week = as.numeric( trdays %in% 1:2 )
)
Unweighted Counts
Count the unweighted number of records in the survey sample, overall and by groups:
sum( weights( nps_design , "sampling" ) != 0 )
svyby( ~ one , ~ age_category , nps_design , unwtd.count )
Weighted Counts
Count the weighted size of the generalizable population, overall and by groups:
svytotal( ~ one , nps_design )
svyby( ~ one , ~ age_category , nps_design , svytotal )
Descriptive Statistics
Calculate the mean (average) of a linear variable, overall and by groups:
svymean( ~ adlaoa6p , nps_design , na.rm = TRUE )
svyby( ~ adlaoa6p , ~ age_category , nps_design , svymean , na.rm = TRUE )
Calculate the distribution of a categorical variable, overall and by groups:
svymean( ~ gender , nps_design )
svyby( ~ gender , ~ age_category , nps_design , svymean )
Calculate the sum of a linear variable, overall and by groups:
svytotal( ~ adlaoa6p , nps_design , na.rm = TRUE )
svyby( ~ adlaoa6p , ~ age_category , nps_design , svytotal , na.rm = TRUE )
Calculate the weighted sum of a categorical variable, overall and by groups:
svytotal( ~ gender , nps_design )
svyby( ~ gender , ~ age_category , nps_design , svytotal )
Calculate the median (50th percentile) of a linear variable, overall and by groups:
svyquantile( ~ adlaoa6p , nps_design , 0.5 , na.rm = TRUE )
svyby(
~ adlaoa6p ,
~ age_category ,
nps_design ,
svyquantile ,
0.5 ,
ci = TRUE ,
keep.var = TRUE ,
na.rm = TRUE
)
Estimate a ratio:
svyratio(
numerator = ~ adlaoa6p ,
denominator = ~ iadlaoa7 ,
nps_design ,
na.rm = TRUE
)
Subsetting
Restrict the survey design to beneficiaries who live alone:
sub_nps_design <- subset( nps_design , livealone == 1 )
Calculate the mean (average) of this subset:
svymean( ~ adlaoa6p , sub_nps_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( ~ adlaoa6p , nps_design , na.rm = TRUE )
coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )
grouped_result <-
svyby(
~ adlaoa6p ,
~ age_category ,
nps_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( nps_design )
Calculate the complex sample survey-adjusted variance of any statistic:
svyvar( ~ adlaoa6p , nps_design , na.rm = TRUE )
Include the complex sample design effect in the result for a specific statistic:
# SRS without replacement
svymean( ~ adlaoa6p , nps_design , na.rm = TRUE , deff = TRUE )
# SRS with replacement
svymean( ~ adlaoa6p , nps_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( ~ trip_this_week , nps_design ,
method = "likelihood" )
Regression Models and Tests of Association
Perform a design-based t-test:
svyttest( adlaoa6p ~ trip_this_week , nps_design )
Perform a chi-squared test of association for survey data:
svychisq(
~ trip_this_week + gender ,
nps_design
)
Perform a survey-weighted generalized linear model:
glm_result <-
svyglm(
adlaoa6p ~ trip_this_week + gender ,
nps_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 NPS users, this code replicates previously-presented examples:
library(srvyr)
nps_srvyr_design <- as_survey( nps_design )
Calculate the mean (average) of a linear variable, overall and by groups:
nps_srvyr_design %>%
summarize( mean = survey_mean( adlaoa6p , na.rm = TRUE ) )
nps_srvyr_design %>%
group_by( age_category ) %>%
summarize( mean = survey_mean( adlaoa6p , na.rm = TRUE ) )