Skip to content

Instantly share code, notes, and snippets.

@chrishanretty
Created November 11, 2023 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrishanretty/cef9fb079c75e8cbbce61a24d5438be0 to your computer and use it in GitHub Desktop.
Save chrishanretty/cef9fb079c75e8cbbce61a24d5438be0 to your computer and use it in GitHub Desktop.
Quick analysis of BES wave 25 questions on local election turnout
library(tidyverse)
library(haven)
### Replace your file location here
bes <- read_dta("~/Dropbox/bes_data/BES2019_W25_v25.0.dta")
### What was turnout like in the panel?
bes |>
filter(!is.na(localTurnoutRetro)) |>
group_by(localTurnoutRetro) |>
summarize(sumwts = sum(wt)) |>
ungroup() |>
mutate(prop = sumwts / sum(sumwts))
###
### 55% of BES respondents in areas which had local elections reported voting.
###
### This is higher than the reported turnout of 32.0%
###
###
### Of those who did not vote, 3.3% said their main reason was not having photo ID
###
### This is comparable to Electoral Commission research
###
bes |>
filter(localTurnoutRetro == 0) |>
group_by(reasonNonVoter) |>
summarize(sumwts = sum(wt)) |>
ungroup() |>
mutate(prop = sumwts / sum(sumwts)) |>
arrange(desc(prop))
###
### Of those who did not vote, 1.7% had tried to vote
###
bes |>
filter(localTurnoutRetro == 0) |>
group_by(attemptTurnout) |>
summarize(sumwts = sum(wt)) |>
ungroup() |>
mutate(prop = sumwts / sum(sumwts)) |>
arrange(desc(prop))
###
### Of those who tried to vote but could not,
### 25% didn't have valid voter ID
bes |>
filter(attemptTurnout == 1) |>
group_by(reasonForTurnaway_2) |>
summarize(sumwts = sum(wt)) |>
ungroup() |>
mutate(prop = sumwts / sum(sumwts)) |>
arrange(desc(prop))
###
### Of those who tried to vote but could not,
### 18% had voter ID which was not accepted
bes |>
filter(attemptTurnout == 1) |>
group_by(reasonForTurnaway_3) |>
summarize(sumwts = sum(wt)) |>
ungroup() |>
mutate(prop = sumwts / sum(sumwts)) |>
arrange(desc(prop))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment