Freitag, 2. August 2013

Political competition and macroeconomic performance–What does the data say?

 

This paper summarizes empirical evidence from public choice theories and presents new evidence on the influence of unemployment and partisan bias in Austria. Download the paper from here http://sdrv.ms/18WvKgN 

The dataset comes from the European Election Database and Eurostat.

Using the eurostat_r library (get it here: https://github.com/toprach/eurostat_r)  and the following r script you can replicate the table in the paper.

The data sources allow for easy repetition of the analysis for other countries.

 

library(foreign)
library(data.table)
library(texreg)
library(estout)
library(stargazer)
library(plm)

#http://129.177.90.166/nesstar/temp/download69627.tmp/BEEP2009_Download.zip
#http://129.177.90.166/nesstar/temp/download69627.tmp/BEEP2004_Download.zip

election=data.table(read.csv("election.csv"))
setnames(election,"NUTSID","GEO")
setnames(election,"Year","time")
        
election[,SPO:=SPO/Validvotes*100]
election[,OVP:=OVP/Validvotes*100]
election[,FPO:=FPO/Validvotes*100]
election[,BZO:=BZO/Validvotes*100]
election[,Grune:=Grune/Validvotes*100]
election[,other:=100-(SPO+OVP+FPO+BZO+Grune)]
election[,KPO:=KPO/Validvotes*100]
election[,left:=SPO+Grune]
election[,right:=OVP+FPO+BZO]

election[time==1999 | time==2002, BZO:=NA]

source("C:/git/eurostat_r/eurostat_r.r")
unemp=read.eurostat("lfst_r_lfu3rt")
bip=read.eurostat("nama_r_e3gdp")
setnames(unemp,"value","unemp")
setnames(bip,"value","gdp")
unemp$flag=NULL

bip=bip[UNIT=="EUR_HAB_EU",list(GEO,time,gdp)]

j=join(election,unemp)
j=join(j,bip)
j=j[SEX=="T" & AGE=="Y_GE15",]
level2=j[NUTSlevel==2,]
level1=j[NUTSlevel==1,]

j=j[ NUTSlevel==3,]
j$GEO=as.factor(as.character(j$GEO)) # remove unused factors of level 1,2

table(j[,list(time,GEO)])

plmdata=plm.data(j, index=c("GEO","time"), model="twoways")

p_s=plm(SPO ~ unemp ,data=plmdata)
p_o=plm(OVP ~ unemp ,data=plmdata)
p_f=plm(FPO ~ unemp ,data=plmdata)
p_b=plm(BZO ~ unemp ,data=plmdata)

p_g=plm(Grune ~ unemp ,data=plmdata)
p_l=plm(left ~ unemp ,data=plmdata)
p_r=plm(right ~ unemp ,data=plmdata)


sink("unempvotesplm.tex")
s=stargazer(p_s,p_g,p_o,p_f,p_l,omit=levels(j$GEO),
            title="How unemployment influences elections",
            intercept.top=TRUE,covariate.labels="unemployment")

sink()


p_s=plm(SPO ~ gdp ,data=plmdata)
p_o=plm(OVP ~ gdp ,data=plmdata)

 

#the level of gdp does not change the votes
summary(lm(SPO ~ gdp + GEO ,j))
summary(lm(OVP ~ log(gdp) + GEO ,j))
summary(lm(FPO ~ log(gdp) + GEO ,j)) # when unemp high is then FPO gets - other things equal -less votes


######################## graph for median voters

windows(width=7,height=4)
x=seq(-2,2,length=200)
y=dnorm(x)
plot(x,y,type="l", lwd=2, col="blue", axes=F,xlab="",ylab="",
      main="Distribution of voter preferences\n and party positions")
x=seq(-1,1,length=100)
y=dnorm(x)

polygon(c(-1,x,1),c(0,y,0),col="gray")
axis(1,labels=F)
axis(1,at=c(-1,0,1),labels=c("Left","Median","Right"))
savePlot(filename="distrvoters.png",type="png")
dev.off()
######################################################################
##election denmark

fetchfile=function(x){
  data.table(read.csv(x))
}
files=c("DKPA1994_Download_F1.csv",
        "DKPA1998_Download_F1.csv",
        "DKPA2001_Download_F1.csv",
        "DKPA2005_Download_F1.csv",
        "DKPA2007_Download_F1.csv")
library(plyr)
election=data.table(ldply(files,fetchfile))
unemp=read.eurostat("lfst_r_lfu3rt")

setnames(election,"NUTSID","GEO")
setnames(election,"Year","time")

j=join(election,unemp)
j=j[SEX=="T" & AGE=="Y_GE15",]
j=j[GEO!="DK" & GEO!="DK0" ,]
j=j[ NUTSlevel==3,]
j$GEO=as.factor(as.character(j$GEO)) # remove unused factors of level 1,2