# Construct Democracylevel Variables

load("Daten/X-Polity//xpolity_1800-2013.RData")
p4 <- subset(p4, select = c(ccode, year, polity2, xpolity))
p4 <- rename(p4, c("ccode"="actorid"))
Master <- join(Master, p4, type="left", by=c("actorid", "year"), match="all")

# Highest / mature democracies (dummy variables)
Master$polity2_highest <- 0
Master$polity2_highest[Master$polity2 > 7] <- 1

Master$xpolity_highest <- 0
Master$xpolity_highest[Master$xpolity > 5] <- 1

# Quadratic terms
Master$polity2_quadratic <- Master$polity2^2
Master$xpolity_quadratic <- Master$xpolity^2

rm(p4)
