This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
### Write a function to download the data from the IPU | |
dl_data <- function(y, m) { | |
url <- paste0("https://data.ipu.org/api/women-ranking.csv?load-entity-refs=taxonomy_term%2Cfield_collection_item&max-depth=2&langcode=en&month=", | |
m, | |
"&year=", | |
y) | |
download.file(url, destfile = paste0("ipu_", y, m, ".csv")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Load the necessary libraries | |
library(sf) | |
library(tidyverse) | |
### Read in the shapefile | |
### Downloaded from https://geoportal.statistics.gov.uk/datasets/ons::local-authority-districts-december-2022-boundaries-uk-bfc/explore?location=55.215430%2C-3.316939%2C6.61 | |
lad_shp <- st_read("LAD_DEC_2022_UK_BFC.shp") | |
### Read in the list of coordinates | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(vdemdata) | |
library(tidyverse) | |
library(ggflags) | |
library(countrycode) | |
library(hrbrthemes) | |
### Get the V-Dem data in | |
data("vdem") | |
dat <- vdem |> | |
distinct(country_name, country_text_id, year, | |
v2x_polyarchy, v2x_polyarchy_sd) |> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(hrbrthemes) | |
### This section reads in the data -- scroll down for the code that | |
### generates the figures and the graphics | |
tibble::tribble( | |
~aye_vote, ~ONSConstID, ~Constituency, ~MP, ~Party, ~ConstyOpposition, ~ConstyOpposition_sd, | |
1, "E14000530", "Aldershot", "Leo Docherty", "Conservative", 1.67320394423204, 0.0170138236227471, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Purpose of this code: plot the proportion of people in each CSES | |
### wave 5 study who can place themselves on a left-right scale. | |
### You will need to have downloaded the CSES 5 data somewhere | |
library(tidyverse) | |
library(ggtext) | |
library(RColorBrewer) | |
library(countrycode) | |
library(hrbrthemes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(hrbrthemes) | |
library(ggtext) | |
dat <- read.csv("view_cabinet.csv") | |
dat <- dat %>% | |
group_by(country_name_short, | |
country_id, | |
election_date, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Replicate | |
### | |
### Kim, Nam Kyu. "Previous Military Rule and Democratic Survival." Journal of Conflict Resolution 65, no. 2-3 (2021): 534-562 | |
### | |
### including an additional covariate for a hereditary head of state | |
### | |
library(rio) | |
library(tidyverse) | |
library(vdemdata) | |
library(countrycode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(rio) | |
library(hrbrthemes) | |
### (1) Get files in | |
### Parish to Ward | |
### https://geoportal.statistics.gov.uk/datasets/ons::parish-to-ward-to-local-authority-district-december-2020-lookup-in-england-and-wales-v2/about | |
par2ward <- read.csv("Parish_to_Ward_to_Local_Authority_District__December_2020__Lookup_in_England_and_Wales_V2.csv") | |
par2ward$FID <- NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(cmdstanr) | |
library(MCMCpack) | |
### log PDF is based on eqn. 3 in https://www2.seas.gwu.edu/~dorpjr/Publications/Bookchapter/MarcelDekker2003.pdf | |
stan_code <- | |
" | |
functions { | |
real orddir_lpdf(vector y, real[] alpha) { | |
int K = size(alpha); |