Did Brexit in 2016 set the UK on a path of democratic backsliding? We can study this with a synthetic control design using historical data on countries’ regimes. The code to set this up is not that simple.
Start by loading relevant data:
vdemeu <- read.csv("https://raw.githubusercontent.com/jnseawright/PS312/refs/heads/main/vdemeu.csv")
#devtools::install_github("vdeminstitute/vdemdata")
library(vdemdata)
vdem2025 <- vdem
#Remove some variables from vdemeu that don't match the other dataset
vdemeu$X <- NULL
vdemeu$event <- NULL
vdemeu$accession <- NULL
#Build a list of all the countries that didn't have Brexit
brexitcontrols <- unique(vdemeu$country_name)
#Combine the two datasets together
brexitdata <- rbind(vdemeu, vdem2025[vdem2025$country_name=="United Kingdom",])
#Select our relevant time frame
brexitdata <- brexitdata[brexitdata$year>1993 & brexitdata$year<2022,]
#Make the ID variable numeric
brexitdata$countrynum <- as.integer(as.factor(brexitdata$country_id))
The core of the synthetic control method is the dataprep function. Work with your group to complete the missing part of the code below and run the result.
library(Synth)
brexit.prep <- dataprep(
foo=brexitdata,
#Add a list of predictor variables that can help forecast countries' level of democracy, that don't have much missing data, and that you think probably aren't caused by Brexit. List them as a set of strings separated by commas: c("variable1", "variable2", "variable3")
predictors=c(
),
dependent="v2x_libdem",
unit.variable="countrynum",
time.variable="year",
#Here is where we specify the unit where the treatment happens
treatment.identifier="United Kingdom",
controls.identifier=brexitcontrols,
#Here is where we specify the time frame for the treatment, showing the time before and after it happens.
time.predictors.prior=c(1994:2015),
time.optimize.ssr=c(2016:2019),
time.plot=c(1994:2019),
unit.names.variable="country_name"
)
Now we’re on the downhill slope! We just have to run the synthetic control process and plot the results. Run the following code, filling in any holes where capital words appear.
brexit.synth <- synth(brexit.prep)
path.plot(synth.res=brexit.synth, dataprep.res=brexit.prep,
Ylab="Democracy Level", Legend=NA, tr.intake=2016,
Ylim=c(0,1) , Main="United Kingdom"
)
As a group, evaluate the credibility of your results and interpret their meaning. Send your figure and a paragraph explaining your estimator and explaining your results to your TA.