2016 Australian Federal Election Flexdashboard
Here in the land down under we’ve finally completed our Federal election. We complain that it seems to go on for too long, but it’s a brief distraction compared to the USA electoral process. I managed to do a small analysis on the votes at a finer scale than I thought would be available, and created a flexdashboard to present the results. Given that I couldn’t make it to GovHack this year, this open-data analysis sort of makes up for it.
This year turned out to be quite eventful (when aren’t they these days?) with what might appear to an outside observer to be a conspired attempt at a perfect split vote (a hung parliament).
In the end, it seems the incumbent Liberal/National Coalition managed to form government in their own right by the slimmest of margins, with one electorate triggering a recount when the margin dropped to a single vote. The final split ended up being a mere 37 votes.
Things run a little more smoothly here because we (functionally) follow the Westminster system for electing a party rather than a specific leader, a fact that has resulted in our having 5 Prime Ministers (4 unique) in the last 6 years, despite elections being held every 4 years.
Structurally, we are similar to the United States Congress in that we have a House of Representatives elected from single-member constituencies of approximately equal population, and a Senate consisting of an equal number of Senators from each state, regardless of population. Given this combination of systems, it’s sometimes referred to as a ‘Washminster‘ system. The election is decided based on how many electorates each party can win such that they can form a majority government. There are currently 150 electorates, so a party requires 76 to gain full control without having to go into talks with the minor parties.
This year, with voting completed and counted (eventually) the Liberal/National Coalition held 76 seats and can govern in their own right. Given that electorates are defined to be of approximately equal population sizes, this means that the majority of people voted for that party, right? Right? Let’s see.
In terms of open data, Australia doesn’t do too bad. We have a few underutilised resources, such as data.gov.au (building an R interface to that site is on my to-do list), the Australian National Data Service, Research Data Australia, and GovPond. The Australian Electoral Commission (via the Virtual Tally Room) is one of the better agencies in terms of data availability.
When I visited the Virtual Tally Room to find out what level of data was available, I was rather impressed to find that the results weren’t only available at the electorate level, but the polling place (‘booth’) level even! Not the individual voters of course, that would be a bit much, but the 7741 polling places around the country with their latitudes/longitudes and votes per party. Not too bad, and certainly an opportunity to look more closely.
This seemed like a good opportunity to try out a flexdashboard and the new crosstalk feature. I’ll skip the minor details here and disappoint you early in that I didn’t end up using crosstalk (properly, it’s still in there); it turns out it’s great for subsetting a data set, not so great for performing further aggregations on the data after subsetting. Not to worry.
I managed to grab a shapefile of the electorates from the AEC
Each of those boxes should roughly contain an equal population of voters. I merged the polling data with these to produce a map of each state with electorates colored by winning party and polling places colored by the party with the most votes.
There’s two caveats to this. Firstly, while we’re required to vote within our electorates (compulsory voting, or at least getting your name ticked off as present) it’s an assumption that people vote at the closest polling place to where they live or work, in which case the distribution of people isn’t biasing the result at each polling place. That might not necessarily be true – perhaps people who vote for a particular party tend towards the city center on election day.
Secondly, there’s no requirement on polling places that they each cater for the same number of people. Electorates are population-balanced, but a polling place could have anywhere from 0 to all of the voters for that electorate show up on that day (we tend to run BBQs at polling places serving up democracy sausages, so people do move around to find the best one). I did try scaling the polling place markers by the number of votes at each but something screwy was going on with the markers disappearing on zoom-changes so I’ve left them all the same.
With those in mind, we can now have a look at how polarised each electorate is and compare it to the overall winner. Here’s the result, hosted over at shinyapps.io. I’ve added a tab for both the first preference votes and two-party preferred (this data isn’t completely available at the time of writing, but I’ll keep updating it).
In my home state of South Australia it’s clear that there’s a big geographical split between the northern and central/southern suburbs
as well as a clear preference away from the two major parties in the country areas to the East. Voters in the more regional North seemed to not get their way, likely outweighed by the larger population towards the state capital of Adelaide.
In Tasmania, in the electorate (Denison) that contains the state capital of Hobart, most polling places appear to be overwhelmingly supportive of an independent candidate.
Looking at the number of polling places won, it certainly seems like it was a landslide
However, the population at just a few polling places showed the fuller story
In our most populous state of New South Wales, things look fairly consistent within electorates (the dark green here represents the National Party which together with the Liberal party (blue) form the Liberal/National Coalition)
In Victoria, the state capital of Melbourne fails to shake its hipster stereotype and had quite the clearly defined region of green (our left-wing Greens party)
How about that ‘approximately equal population’ assumption? It’s fairly easy to count up the number of votes in each state/division and compare them
It’s clear that ACT, with only two electorates, could in principle divided up more evenly, while the Northern Territory only really has enough people to support one electorate at their current size.
I’ll leave the rest of the exploring to the reader. Go play with the dashboard and let me know what you find. The source code is available either in the header bar or a link in the sidebar. I’m absolutely interested in learning what I perhaps could have done differently/better, so hit me up either in the comments, on GitHub, or on Twitter.View this post on GitHub