New Zealand · R

A National Flag

So New Zealand just had a referendum on changing its flag (answer- yeah nah, not to that flag), which means we can play with the results data.

Initially the Prime Minister, and Parliamentary leader of the National Party, strongly linked himself to the alternative choice for a flag (even before it was an official alternative choice) while later decrying politicisation of the referendum.

To shed a little light on this we can take the referendum results and compare the electorate results for wanting to change the flag to the Prime Minister’s preferred design to the electoral support that various political parties have, as expressed at the last general election. This gives us a bunch of graphs

Other political parties seem to have a relationship as well, however percentage support is a zero sum game- as National is the single biggest party, in electorates where National is strong other parties are, by definition, weaker than electorates where National is weak.

One good way of testing this is constructing a linear model of the relationship between National Party support and changing the flag, and then comparing the support of other parties to the support for change once the expected support effects of the National Party have been removed (the residuals of the model) if there is any trend then that is related to the political effects of that party.

The short answer is that there is no trend once the effects of National Party are removed, so we can describe the politicisation as being around the National Party only. In places where there was a lot of National Party support there was a lot of change support, in places without a lot of National Party support there was not a lot of change support.

Some stray thoughts about follow-on things that people might want to look into:

  • looking at turnout in relation to both change support and National Party support might be interesting, in a “did the politicisation effect turnout” kind of way.
  • linking the residuals to the demographic information of the electorates could be interesting in a “aside from the National Party effect who was for or against” kind of way
  • figuring out the “hypothetical apolitical referendum” level of support for change to get a sense of the national (small n) mood for change, rather than the mood for National Party led change.


And in a reproducible kind of way, here is the code used to do the above

url <- ""
url %>%
read_html() %>%
html_nodes(xpath='//html/body/div/table') %>%
html_table(fill=TRUE) -> flegs
flegs <- flegs[[1]]
flegs <- flegs[2:72,c(1,7)]
election <- read.csv("", skip=3, header=FALSE, stringsAsFactors = FALSE)
eh1 <- read.csv("", skip=1, header=FALSE, nrows=1, stringsAsFactors = FALSE)
eh2 <- read.csv("", skip=2, header=FALSE, nrows=1, stringsAsFactors = FALSE)
h1 <- unlist(eh1)
h1[] <- ""
h2 <- unlist(eh2)
newheads <- make.names(paste(h1,c("",h1[2:length(h1)-1]),h2, sep=""))
names(election) <- newheads
election <- election[-1*c(65,73,74),]
flegs$Electorate <- gsub(".*- ", "", flegs$Electorate )
names(flegs) <- c("Electorate", "ferners")
flegs$ferners <- gsub("%", "", flegs$ferners )
flegs$ferners <- as.numeric(flegs$ferners)
refdata <- merge(election,flegs, by.x="Electoral.District", by.y="Electorate")
election$Electoral.District[!(election$Electoral.District %in% flegs$Electorate)]
flegs$Electorate[!(flegs$Electorate %in% election$Electoral.District)]
election$Electoral.District[election$Electoral.District == "Rangitīkei"] <- "Rangitῑkei"
refdata <- merge(election,flegs, by.x="Electoral.District", by.y="Electorate")
refdata <- refdata[,c(1,3,5,7,9,11,13,15,17,19)]
for (i in 2:9){
plot(refdata[,i],refdata$ferners, main=names(refdata)[i], ylim=c(0,60), pch=19, cex=0.8, col="#33333366", frame.plot=FALSE, xlab=names(refdata)[i], ylab="Support for Change")

#removing National politcal party partisanship

linearmodel <- lm(ferners ~ NATIONAL.PARTYPercentage, data=refdata)
refdata$postnational <- linearmodel$residuals
for (i in 2:9){
plot(refdata[,i],refdata$postnational, main=paste("Residuals", names(refdata)[i]), ylim=c(-5,7), pch=19, cex=0.8, col="#33333366", frame.plot=FALSE, xlab=names(refdata)[i], ylab="residuals after Nat removed")




2 thoughts on “A National Flag

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s