Visualizing Euro 2012: First Group Games

Now that every team has played a match it will be interesting to see how this has affected the (inverse) odds of victory. Since the plot in my last post was a bit ‘busy’, I have decided to use the facet_wrap function in gglplot2 to stratify by group. Also, re-producing the ‘busy’ plot from the last post yields the following. Germany, despite not playing well, has gained, while the Netherlands, despite playing quite well, have declined. These two countries will play each other in the next round, so it will be interesting to see how a victory for the Netherlands would change these graphics.

Data and code:

# after loading data as object called eur
n <- dim(eur)
eur <- t(eur[1:n,])
dat <- NULL
for(i in 1:n){dat <- data.frame(rbind(dat,cbind(eur[-1,i],names(eur[-1,i]),i)))}

dat\$V1 <- 1/as.numeric(as.character(dat\$V1))
dat\$V3 <- as.character(dat\$V2)
dat\$V3[dat\$i!=n] <- c("")
dat\$group <- ifelse(dat\$V2 %in% c("RUS","GRE","POL","CZE"),"Group.A","Group.D")
dat\$group <- ifelse(dat\$V2 %in% c("GER","NED","POR","DEN"),"Group.B",dat\$group)
dat\$group <- ifelse(dat\$V2 %in% c("IRL","CRO","ITA","ESP"),"Group.C",dat\$group)
dat\$i <- as.numeric(as.character(dat\$i))

ggplot(dat, aes(x=i, y=V1, colour = V2, group=V2, label=V3)) +
geom_line(size=0.8) + geom_point(size=4, shape=21, fill="white") + #theme_bw() +
geom_text(hjust=-0.3, vjust=0) +
scale_x_continuous('Day',limits=c(1,(n+0.4)),breaks=1:n) +
scale_y_continuous('1/Odds') +
theme_bw() +
opts(title = expression("Euro 2012, Inverse Odds of Victory"),
legend.position=c(80,80))

ggplot(dat, aes(x=i, y=V1, colour = V2, group=V2, label=V3)) +
geom_line(size=0.8) + geom_point(size=4, shape=21, fill="white") + #theme_bw() +
geom_text(hjust=-0.3, vjust=0.4) +
scale_x_continuous('Day',limits=c(1,(n+0.8)),breaks=1:n) +
scale_y_continuous('1/Odds') +
facet_wrap( ~ group, ncol = 2, scales="free_y") +
theme_bw() +
opts(title = expression("Euro 2012, Inverse Odds of Victory"),
legend.position=c(80,80))

Temperature Change in Ireland

Has Ireland gotten any warmer? Ask any punter on the street and they will happily inform you of wild swings, trends and dips. “Back when I was a child”, “when I was younger”, or “years ago” are the usual refrains.

What’s the evidence? To answer this, I will use the temperature data from my previous post alongside the R package bcp. The bcp package stands for Bayesian Change Point, and it implements the change point methodology of Barry & Hartigan (1993). A good overview of how to use the bcp R package is offered by Erdman & Emerson (2007).

These series are monthly and run from 1866 to 2011. There are two measures for each month, the average daily high or low. I use both here, and perform the multivariate bcp procedure for each month separately, with average high and low for each month. The figure above shows the output produced when I look at the January temperatures. Clearly, there are no major changes. The January temperature in Ireland is the same now as it was in 1866. The results for the other months are very similar. However, there are some changes in the October series, with both the posterior means for both max and min temperatures increasing by around 1 degree Celsius (see below). Has Ireland gotten warmer? Yes, but only in October, for some reason unknown to me.

# with web-scraped data from the previous post

library(bcp)

cold <- NULL
for (i in 1:12){
mins <- armagh[armagh[,2]==i,4]
cold <- cbind(cold,mins)
}
cold <- cold[14:159,]

warm <- NULL
for (i in 1:12){
maxs <- armagh[armagh[,2]==i,3]
warm <- cbind(warm,maxs)
}
warm <- warm[14:159,]

bcp.0 <- bcp(cbind(cold[,1],warm[,1]), burnin = 1000, mcmc = 5000)
plot(bcp.0)
bcp.0 <- bcp(cbind(cold[,10],warm[,10]), burnin = 1000, mcmc = 5000)
plot(bcp.0)