setwd("~/Downloads")
mp_setapikey("manifesto_apikey.txt")
alldata <- mp_maindataset()
turkey <- subset(alldata, countryname== "Turkey")
turkey$rile2 <- rile(turkey) cbind(turkey$rile2, turkey$rile) cor(turkey$rile, turkey$rile2)
#there are small differences but check is okay#
attach(turkey)
turkey$year <- substr(turkey$edate, 0, 4)
plot <- ggplot(turkey,aes(rile2,pervote,color=factor(year), label=(partyabbrev),size=5) )
left_right_plot <- plot + geom_text(check_overlap = TRUE, size=3) + labs(x="Left-Right", y="Vote", colour="Year") + theme(legend.key.size= unit(0.2, "cm")) + guides(col = guide_legend(ncol = 2))
turkey$issues <- issue_attention_diversity(turkey, method="herfindahl", prefix=("per"), aggregate_categories = list(c(101, 102), c(104, 105), c(107, 109), c(108, 110), c(203, 204), c(301, 302), c(406, 407), c(409, 414), c(504, 505), c(506,507), c(601, 602), c(603, 604), c(607, 608), c(701, 702))) attach(turkey)
correl <- cbind(pervote, rile, issues) cor(correl)
fit <- lm(pervote ~ rile + issues, data=turkey) summary(fit) fit_interact <- lm(pervote ~ rile + issues + rile*issues, data=turkey) summary(fit_interact) anova(fit, fit_interact,test="Chisq")
issues_year=aggregate(issues~edate, FUN=function(x) c(mean=mean(x))) issue_plot <- ggplot(data=issues_year, aes(x=edate, y=issues, group=1)) + geom_point(size=1) +xlab("Election")+ylab("Issues")+ggtitle("Issue Diversity") + geom_smooth(fill="red", colour="red", size=1)
{r pressure, echo=FALSE}
issue_plot