Member-only story
Applying Weights
What difference does applying survey weights make?
Weights adjust survey responses, when producing survey statistics.
This article looks at R code for applying survey weights. We find the difference that applying those weights make.
Importing the data
This article uses European Social Survey data for the United Kingdom. NatCen conducted the ninth wave, interviewing 2,204 UK adults aged 15 or over. These face-to-face interviews were between 31st August 2018 and 22nd February 2019.
If there were to be a new referendum tomorrow, would you vote for the UK to remain a member of the European Union or leave the European Union?
First, let’s import the SAS data file into R, with the haven package:
ESS09GB_sav <- read_sav("ESS9GB.sav")
In its current form, responses to the EU referendum vote intention question look like:
- 1: Remain a member of the European Union;
- 2: Leave the European Union;
- 33: Would submit a blank ballot paper.
There are other coded responses too. The data file does not code unsure or refused responses. This is not as useful as it could be. We need to replace the enumerated responses with what they mean in the code book:
ESS09GB_sav_df <- ESS09GB_sav %>%…