-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Surveys - ESS #33
Comments
ESS now featured in Session 12 via a spatial viz example. |
|
z <- fs::dir_ls(regexp = "*.zip", recurse = TRUE)
v <- tibble()
for (i in z) {
cat(fs::path_file(i))
d <- unzip(i, exdir = tempdir())
f <- str_subset(d, "dta$")
cat(" ->", fs::path_file(f), "...\n")
d <- haven::read_dta(f)
n <- names(d)
n <- n[ n %in% c("essround", "cntry", "psu", "idno", "stratify", "stratum",
"dweight", "pspwght", "pweight", "prob", "anweight") ]
v <- bind_rows(v, tibble(file = f, n))
}
v %>%
mutate(file = fs::path_file(file)) %>%
pivot_wider(values_from = n, names_from = n) %>%
mutate(essround = as.integer(str_extract(file, "\\d+"))) %>%
arrange(essround)
|
Did some more tests, found weird things: gergness/srvyr#157 Best guess, based on weighting guide: as_survey_design(ids = psu,
strata = c(cntry, stratum),
nest = TRUE,
weights = anweight) |
More tests with other designs. Conclusions:
library(srvyr)
library(tidyverse)
ess9 <- readr::read_rds("https://f.briatte.org/temp/ess9_extract.rds")
# Andy Fugard's design
ess9_af1 <- ess9_extract %>%
as_survey_design(ids = idno, strata = cntry, nest = TRUE,
weights = pspwght)
# Fugard, using PSU
ess9_af2 <- ess9_extract %>%
as_survey_design(ids = psu, strata = cntry, nest = TRUE,
weights = pspwght)
# weighting guide + cntry
ess9_wg1 <- ess9_extract %>%
as_survey_design(ids = psu,
strata = c(cntry, stratum), # adding cntry
nest = TRUE,
weights = anweight)
# weighting guide, no cntry
ess9_wg2 <- ess9_extract %>%
as_survey_design(ids = psu,
strata = stratum, # as recommended
nest = TRUE,
weights = anweight)
# Vegetti's design -- implicit `ids = idno`
ess9_mv1 <- ess9_extract %>%
as_survey_design(weights = c(dweight, pspwght))
# Vegetti, using PSU
ess9_mv2 <- ess9_extract %>%
as_survey_design(ids = psu, weights = c(dweight, pspwght))
# Oberski's design -- implicit `nest = TRUE`
ess9_do <- ess9_extract %>%
as_survey_design(ids = psu, strata = stratum, weights = prob)
# Stefan Zins' design
# https://github.com/ropensci/essurvey/issues/39#issuecomment-507855290
ess9_sz <- ess9_extract %>%
as_survey_design(ids = psu, strata = stratum, weights = dweight)
# results -----------------------------------------------------------------
list("AF_idno" = ess9_af1, "AF_psu" = ess9_af2,
"WG_cntry" = ess9_wg1, "WG_stratum" = ess9_wg2,
"MV_idno" = ess9_mv1, "MV_psu" = ess9_mv2, "DO_psu" = ess9_do,
"SZ_psu" = ess9_sz) %>%
map_dfr(
~ .x %>%
filter(cntry == "GB") %>%
group_by(wltdffr_group) %>%
summarise(prop = srvyr::survey_mean(vartype = "se")),
.id = "design"
) %>%
filter(wltdffr_group == "Fair") %>%
arrange(-prop_se)
|
Availability of weighting vars:
… so, use ESS 9 or 10 in examples, or use 7 or 8 for one more example of a merge. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one is complex enough to be its own issue…
Weighting guide
https://www.europeansocialsurvey.org/methodology/ess_methodology/data_processing_archiving/weighting.html
https://www.europeansocialsurvey.org/docs/methodology/ESS_weighting_data_1_1.pdf
From the weighting guide, v1.1 (2020), page 7:
The guide asks for the creation of
anweight
('analytical weights') from the following variables:Once
anweight
exists, weighting guide instructs the following design:Details on analytical weights (ESS9+)
Quoting again from the weighting guide:
Full range of weighting variables, quoted from ESS9 codebook:
idno
- Respondent's identification numbercntry
- Countrydweight
- Design weightpspwght
- Post-stratification weight including design weightpweight
- Population size weight (must be combined withdweight
orpspwght
)anweight
- Analysis weightprob
- Sampling probabilitystratum
- Sampling stratumpsu
- Primary sampling unitNotes:
pspwght
includesdweight
anweight
is just the product ofpspwght
andpweight
prob
Discussions
InductiveStep/R-notes#1
ropensci/essurvey#39
ropensci/essurvey#9 (comment)
Second link right above recommends the following for ESS4:
Example: Andi Fugard, ESS9
Intermediate Quantitative Social Research, Birkbeck, University of London (2017-2020)
https://inductivestep.github.io/R-notes/complex-surveys.html
Working on a multi-country example:
From the text:
Example: Federico Vegetti, ESS7
Introduction to Survey Statistics, University of Heidelberg, 2018
https://federicovegetti.github.io/teaching/heidelberg_2018/lab/sst_lab_day2.html
When working on countries separately:
When working on all countries together:
Example: Daniel Oberski, ESS7
http://asdfree.com/european-social-survey-ess.html
Working on a single country (Belgium) after merging the data to the SDDF file:
The text was updated successfully, but these errors were encountered: