Your task for today is to use a difference-in-differences model to test whether transition to democracy increases the risk of interstate war.
Start by loading the quality of governance data into R Studio:
#Add libraries to load and process data
#install.packages("devtools")
#devtools::install_github("ropengov/rqog")
library(rqog)
#Read in the Quality of Governance dataset
qog_ts <- read_qog(which_data = "standard", data_type = "time-series")
## Local file not found.
## Downloading QoG qog_std_ts_jan23.csv data
## from http://www.qogdata.pol.gu.se/data/qog_std_ts_jan23.csv
## in file: C:\Users\jnsno\AppData\Local\Temp\RtmpI1zgvh/rqog/qog_std_ts_jan23.csv
## Reading cache file C:\Users\jnsno\AppData\Local\Temp\RtmpI1zgvh/rqog/qog_std_ts_jan23.csv
Use the codebook on the QOG website to find a variable that measures interstate military conflict and a variable that measures a country’s level of democracy. Make sure that your variable measuring democracy is coded as 0 for authoritarian country-years and 1 for democratic country-years. This may require some modification.
Carry out a difference-in-differences analysis using code modeled after the example below. (I am using different treatment and outcome variables, obviously.)
The code below uses a contemporary difference-in-differences technique called interactive fixed effects. While the details are beyond the scope of this course, the idea is that it provides an estimate for fixed effect without some of the specific technical limitations of the approaches discussed in the textbook.
qog_ts$central_bank_independence <- 1*(qog_ts$cbi_cbiu>0.5)
library(fect)
## Warning: package 'fect' was built under R version 4.5.3
example_difindif <- fect(wdi_unempilo ~ central_bank_independence, index = c("cname", "year"),
force = "two-way", data = qog_ts, method="ife",
min.T0=1, se=1, na.rm = TRUE)
## For identification purposes, units whose number of untreated periods <1 are dropped automatically.
## Parallel computing ...
## Warning: package 'fect' was built under R version 4.5.3
## Warning: package 'doFuture' was built under R version 4.5.3
## Warning: package 'mvtnorm' was built under R version 4.5.3
## Warning: UNRELIABLE VALUE: One of the foreach() iterations ('doFuture-1')
## unexpectedly generated random numbers without declaring so. There is a risk
## that those random numbers are not statistically sound and the overall results
## might be invalid. To fix this, use '%dorng%' from the 'doRNG' package instead
## of '%dopar%'. This ensures that proper, parallel-safe random numbers are
## produced. To disable this check, set option 'doFuture.rng.onMisuse' to
## "ignore".
## Warning: package 'fect' was built under R version 4.5.3
## Warning: package 'doFuture' was built under R version 4.5.3
## Warning: package 'mvtnorm' was built under R version 4.5.3
## Warning: UNRELIABLE VALUE: One of the foreach() iterations ('doFuture-2')
## unexpectedly generated random numbers without declaring so. There is a risk
## that those random numbers are not statistically sound and the overall results
## might be invalid. To fix this, use '%dorng%' from the 'doRNG' package instead
## of '%dopar%'. This ensures that proper, parallel-safe random numbers are
## produced. To disable this check, set option 'doFuture.rng.onMisuse' to
## "ignore".
## Warning: package 'fect' was built under R version 4.5.3
## Warning: package 'doFuture' was built under R version 4.5.3
## Warning: package 'mvtnorm' was built under R version 4.5.3
## Warning: UNRELIABLE VALUE: One of the foreach() iterations ('doFuture-3')
## unexpectedly generated random numbers without declaring so. There is a risk
## that those random numbers are not statistically sound and the overall results
## might be invalid. To fix this, use '%dorng%' from the 'doRNG' package instead
## of '%dopar%'. This ensures that proper, parallel-safe random numbers are
## produced. To disable this check, set option 'doFuture.rng.onMisuse' to
## "ignore".
## Warning: package 'fect' was built under R version 4.5.3
## Warning: package 'doFuture' was built under R version 4.5.3
## Warning: package 'mvtnorm' was built under R version 4.5.3
## Warning: UNRELIABLE VALUE: One of the foreach() iterations ('doFuture-4')
## unexpectedly generated random numbers without declaring so. There is a risk
## that those random numbers are not statistically sound and the overall results
## might be invalid. To fix this, use '%dorng%' from the 'doRNG' package instead
## of '%dopar%'. This ensures that proper, parallel-safe random numbers are
## produced. To disable this check, set option 'doFuture.rng.onMisuse' to
## "ignore".
## Warning: package 'fect' was built under R version 4.5.3
## Warning: package 'doFuture' was built under R version 4.5.3
## Warning: package 'mvtnorm' was built under R version 4.5.3
## Warning: UNRELIABLE VALUE: One of the foreach() iterations ('doFuture-5')
## unexpectedly generated random numbers without declaring so. There is a risk
## that those random numbers are not statistically sound and the overall results
## might be invalid. To fix this, use '%dorng%' from the 'doRNG' package instead
## of '%dopar%'. This ensures that proper, parallel-safe random numbers are
## produced. To disable this check, set option 'doFuture.rng.onMisuse' to
## "ignore".
## Warning: package 'fect' was built under R version 4.5.3
## Warning: package 'doFuture' was built under R version 4.5.3
## Warning: package 'mvtnorm' was built under R version 4.5.3
## Warning: UNRELIABLE VALUE: One of the foreach() iterations ('doFuture-6')
## unexpectedly generated random numbers without declaring so. There is a risk
## that those random numbers are not statistically sound and the overall results
## might be invalid. To fix this, use '%dorng%' from the 'doRNG' package instead
## of '%dopar%'. This ensures that proper, parallel-safe random numbers are
## produced. To disable this check, set option 'doFuture.rng.onMisuse' to
## "ignore".
## Warning: package 'fect' was built under R version 4.5.3
## Warning: package 'doFuture' was built under R version 4.5.3
## Warning: package 'mvtnorm' was built under R version 4.5.3
## Warning: UNRELIABLE VALUE: One of the foreach() iterations ('doFuture-7')
## unexpectedly generated random numbers without declaring so. There is a risk
## that those random numbers are not statistically sound and the overall results
## might be invalid. To fix this, use '%dorng%' from the 'doRNG' package instead
## of '%dopar%'. This ensures that proper, parallel-safe random numbers are
## produced. To disable this check, set option 'doFuture.rng.onMisuse' to
## "ignore".
## Warning: package 'fect' was built under R version 4.5.3
## Warning: package 'doFuture' was built under R version 4.5.3
## Warning: package 'mvtnorm' was built under R version 4.5.3
## Warning: UNRELIABLE VALUE: One of the foreach() iterations ('doFuture-8')
## unexpectedly generated random numbers without declaring so. There is a risk
## that those random numbers are not statistically sound and the overall results
## might be invalid. To fix this, use '%dorng%' from the 'doRNG' package instead
## of '%dopar%'. This ensures that proper, parallel-safe random numbers are
## produced. To disable this check, set option 'doFuture.rng.onMisuse' to
## "ignore".
example_difindif
## Call:
## fect.formula(formula = wdi_unempilo ~ central_bank_independence,
## data = qog_ts, na.rm = TRUE, index = c("cname", "year"),
## force = "two-way", method = "ife", se = 1, min.T0 = 1)
##
## ATT:
## ATT S.E. CI.lower CI.upper p.value
## Tr obs equally weighted 0.6348 0.4347 -0.2173 1.487 0.1442
## Tr units equally weighted 0.2869 0.3694 -0.4370 1.011 0.4373
Your job is to assemble an analysis that makes sense to you as a group, interpret the results, and decide together what it does and does not tell us about the causal relationship between democracy and interstate conflict. Send your results and a paragraph you write about your conclusions to your TA!