asdfree icon indicating copy to clipboard operation
asdfree copied to clipboard

add a pew replication example that matches some SE or CI published by pew

Open ajdamico opened this issue 8 years ago • 1 comments

@davidbrae any chance you have some code you can share that matches a complex survey design published by pew?

ajdamico avatar Jan 08 '17 19:01 ajdamico

this does not match anything published, but it's probably the recommended analysis technique

library(survey)
library(lodown)
library(haven)
	

catalog <- get_catalog( "pew" , output_dir = tempdir() )

spring_2015 <- catalog[ catalog[ , "name" ] == "Spring 2015 Survey Data" , ]

lodown( "pew" , catalog = spring_2015, output_dir = tempdir() ,
		your_name = "Anthony Damico" , your_org = "asdfree" ,
		your_phone = "+1 202 596 5331" , your_email = "[email protected]" ,
		agree_to_terms = TRUE )

rda_file <- grep( "\\.rda$" , list.files( spring_2015$output_folder , full.names = TRUE ) , value = TRUE )
		
load( rda_file )

options( survey.lonely.psu = "adjust" )

israel <- x[ as_factor( x$country ) == "Israel" , ]

this_design <- svydesign(ids = ~psu , strata = ~stratum , weight = ~weight , data = israel )

svymean( ~ as_factor( q3 ) , this_design , deff = 'replace' )

ajdamico avatar Jan 17 '17 09:01 ajdamico