World Values Survey (WVS)
The World Values Survey studies changing values and their impact on social and political life in almost one hundred nations.
One table per country per wave, with one row per sampled respondent.
A complex sample survey designed to generalize the population aged eighteen and older in participating countries.
Released about twice per decade since 1981.
Administered as a confederacy, guided by a scientific advisory committee and funded by consortium.
Simplified Download and Importation
The R lodown
package easily downloads and imports all available WVS microdata by simply specifying "wvs"
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( "wvs" , output_dir = file.path( path.expand( "~" ) , "WVS" ) )
lodown
also provides a catalog of available microdata extracts with the get_catalog()
function. After requesting the WVS 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 WVS microdata files
wvs_cat <-
get_catalog( "wvs" ,
output_dir = file.path( path.expand( "~" ) , "WVS" ) )
# wave six only
wvs_cat <- subset( wvs_cat , grepl( "United(.*)States" , full_url ) & wave == 6 )
# download the microdata to your local computer
wvs_cat <- lodown( "wvs" , wvs_cat )
Analysis Examples with the survey
library
Construct a complex sample survey design:
library(survey)
wvs_df <-
readRDS(
file.path( path.expand( "~" ) , "WVS" ,
"wave 6/F00003106-WV6_Data_United_States_2011_spss_v_2016-01-01.rds" )
)
# construct a fake survey design
warning( "this survey design produces correct point estimates
but incorrect standard errors." )
wvs_design <-
svydesign(
~ 1 ,
data = wvs_df ,
weights = ~ v258
)
Variable Recoding
Add new columns to the data set:
wvs_design <-
update(
wvs_design ,
one = 1 ,
language_spoken_at_home =
factor( v247 ,
levels = c( 101 , 128 , 144 , 208 , 426 , 800 ) ,
labels = c( 'chinese' , 'english' , 'french' ,
'japanese' , 'spanish; castilian' , 'other' )
) ,
citizen = as.numeric( v246 == 1 ) ,
task_creativity_1_10 = as.numeric( v232 ) ,
work_independence_1_10 = as.numeric( v233 ) ,
family_importance =
factor( v4 ,
labels = c( 'very' , 'rather' , 'not very' , 'not at all' )
)
)
Unweighted Counts
Count the unweighted number of records in the survey sample, overall and by groups:
sum( weights( wvs_design , "sampling" ) != 0 )
svyby( ~ one , ~ language_spoken_at_home , wvs_design , unwtd.count )
Weighted Counts
Count the weighted size of the generalizable population, overall and by groups:
svytotal( ~ one , wvs_design )
svyby( ~ one , ~ language_spoken_at_home , wvs_design , svytotal )
Descriptive Statistics
Calculate the mean (average) of a linear variable, overall and by groups:
svymean( ~ task_creativity_1_10 , wvs_design , na.rm = TRUE )
svyby( ~ task_creativity_1_10 , ~ language_spoken_at_home , wvs_design , svymean , na.rm = TRUE )
Calculate the distribution of a categorical variable, overall and by groups:
svymean( ~ family_importance , wvs_design , na.rm = TRUE )
svyby( ~ family_importance , ~ language_spoken_at_home , wvs_design , svymean , na.rm = TRUE )
Calculate the sum of a linear variable, overall and by groups:
svytotal( ~ task_creativity_1_10 , wvs_design , na.rm = TRUE )
svyby( ~ task_creativity_1_10 , ~ language_spoken_at_home , wvs_design , svytotal , na.rm = TRUE )
Calculate the weighted sum of a categorical variable, overall and by groups:
svytotal( ~ family_importance , wvs_design , na.rm = TRUE )
svyby( ~ family_importance , ~ language_spoken_at_home , wvs_design , svytotal , na.rm = TRUE )
Calculate the median (50th percentile) of a linear variable, overall and by groups:
svyquantile( ~ task_creativity_1_10 , wvs_design , 0.5 , na.rm = TRUE )
svyby(
~ task_creativity_1_10 ,
~ language_spoken_at_home ,
wvs_design ,
svyquantile ,
0.5 ,
ci = TRUE ,
keep.var = TRUE ,
na.rm = TRUE
)
Estimate a ratio:
svyratio(
numerator = ~ task_creativity_1_10 ,
denominator = ~ work_independence_1_10 ,
wvs_design ,
na.rm = TRUE
)
Subsetting
Restrict the survey design to seniors:
sub_wvs_design <- subset( wvs_design , v242 >= 65 )
Calculate the mean (average) of this subset:
svymean( ~ task_creativity_1_10 , sub_wvs_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( ~ task_creativity_1_10 , wvs_design , na.rm = TRUE )
coef( this_result )
SE( this_result )
confint( this_result )
cv( this_result )
grouped_result <-
svyby(
~ task_creativity_1_10 ,
~ language_spoken_at_home ,
wvs_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( wvs_design )
Calculate the complex sample survey-adjusted variance of any statistic:
svyvar( ~ task_creativity_1_10 , wvs_design , na.rm = TRUE )
Include the complex sample design effect in the result for a specific statistic:
# SRS without replacement
svymean( ~ task_creativity_1_10 , wvs_design , na.rm = TRUE , deff = TRUE )
# SRS with replacement
svymean( ~ task_creativity_1_10 , wvs_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( ~ citizen , wvs_design ,
method = "likelihood" , na.rm = TRUE )
Regression Models and Tests of Association
Perform a design-based t-test:
svyttest( task_creativity_1_10 ~ citizen , wvs_design )
Perform a chi-squared test of association for survey data:
svychisq(
~ citizen + family_importance ,
wvs_design
)
Perform a survey-weighted generalized linear model:
glm_result <-
svyglm(
task_creativity_1_10 ~ citizen + family_importance ,
wvs_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 WVS users, this code replicates previously-presented examples:
library(srvyr)
wvs_srvyr_design <- as_survey( wvs_design )
Calculate the mean (average) of a linear variable, overall and by groups:
wvs_srvyr_design %>%
summarize( mean = survey_mean( task_creativity_1_10 , na.rm = TRUE ) )
wvs_srvyr_design %>%
group_by( language_spoken_at_home ) %>%
summarize( mean = survey_mean( task_creativity_1_10 , na.rm = TRUE ) )