View longlat2lad.R
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 | |
### |
View wc_groups.R
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) |> |
View 2022-10-20-nc11.R
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, |
View cses5_canplace.R
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) |
View pm_party_rank.R
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, |
View monarchic_survival.R
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) |
View parish_control.R
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 |
View ord_dirichlet.R
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); |
View xdata_positions.R
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(countrycode) | |
library(tidyverse) | |
library(rio) | |
holder <- list() | |
### (0) PartyFacts lookup | |
pf <- read.csv("data/partyfacts-external-parties.csv") | |
### (1) Manifesto Project |
View dontsmoothlineardgps.R
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
### Let's generate some data with a step function | |
library(mgcv) | |
set.seed(1116) | |
nDays <- 200 | |
day <- 1:nDays | |
y <- rnorm(200, 1, 0.25) + I(day > 100) * -0.5 | |
y <- ifelse(y < 0, |
NewerOlder