Feeds:
Posts
Comments

Archive for the ‘Election Simulation’ Category

One of the first things you must decide upon when working on a MC simulation is the granularity of the simulation.

In particle physics the simulation would normally be at the level of the leptons, hadrons and photons we can see in the detectors, or perhaps even at the level of quarks if you are simulating plasma or collisions at higher energies.

There is a tradeoff, though, between accuracy at small scales and other factors such as computing power, data size, and also access to the raw data you need to run the model.  It wouldn’t make sense to try to simulate the weather or a tsunami at the quark-level, for example. Instead you would carve the atmosphere or the ocean up into an appropriately sized grid with granularity anywhere from a hundred meters-or-so up to tens of kilometers.

We have similar issues when trying to simulate election results, and there are a handful of fairly obvious choices for the granularity of the simulation.

  1. Nationwide: basically take the polling averages (with or without considering any margins of error) and assume that that is how the party votes will fall.  Throw in reasonable assumptions about which party’s candidates will win in Epsom, Ohariu, and the seven Maori electorates and you’ve got your result.  This is a good solution if you just want a rough guess at which side will form the government, and it is the level of reporting you typically get from the media and the blogs whenever a new poll is released.
  2. Electorate and candidate-level: This is a little more complicated.  Ideally you would want polling for each electorate, but even without that you can do an alright job by using the relative differences in results between electorates from a previous election.  This will cause problems when electorate boundaries change, however, so while it might have worked alright for the 2011 election it is a bit of a dodgy proposition for 2014.
  3. Polling place-level: The New Zealand Electoral Commission publish polling place analysis by electorate for both the party vote and the electorate candidate vote, helpfully in CSV format as well as HTML.  As with an electorate-level or candidate-level simulation you can do an acceptable job by using the relative differences in results between polling places from a previous election.  Difficulties occur when polling places are discontinued or new polling places are added between elections, and also when there is significant migration, such as that which occurred in and around Christchurch after the 2011 Christchurch Earthquake.
  4. Voter-level: Very handy if you are a political party and you want to tailor campaign material and get-out-the-vote efforts at specific individuals.  In fact, the Obama 2012 campaign data team is well known for performing simulations and doing analysis at this level of granularity. Many New Zealand libraries have copies of the Habitation Directory Habitation Index, which is the electoral role from the most recent 2011 General Election ordered by address.  Assuming you could get your hands on a digital copy then it is at least theoretically possible to geomap individual voters and make reasonable assumptions about their education, income, where they voted and who they voted for, albeit with a lot of attenuation bias.  Unfortunately if that is all the information you have to work with then that is about where you would get stuck.  If you had access to poll results with voting preferences for each person polled then things could start to get interesting, but for obvious reasons only the aggregate polling results are made available to the public.  I wouldn’t be surprised to see the two major parties working on this level of analysis and undertaking highly targeted messaging a few election cycles down the track, but I don’t think anybody in New Zealand is there yet.  Having said that, see the photo in this tweet from @somewhereben for evidence that MPs and volunteers knocking doors are already working to get their hands on some of the voter-level information that will be needed to pull this off.

I still haven’t made a final commitment to what level granularity to work at, but in the mean time I’m playing around with the polling place results try and see if we can understand what happens to voter turnout between elections at that level.  Hopefully the turnout at each polling place will be reasonably constant over time.

Read Full Post »

Final effective party lists for the 2011 NZ General Election, based on candidate election probabilites post below.

This lists order candidates for each party by the probabilty of being elected to parliament as the lowest ranked successful list candidate for their party. In other words, the probability that a party vote for this party will go towards electing this candidate.

For more information please refer to the original effective party lists post.

Effective party list for the National party.

Effective party list for the National party.

A vote for the National party is a vote for Joanne HAYES (41%), Claudette HAUITI (35%), Sam COLLINS (14%), or Aaron GILMORE (5%).

Effective party list for the Labour party.

Effective party list for the Labour party.

A vote for the Labour party is a vote for Deborah MAHUTA-COYLE (36%), Stuart NASH (24%), Rick BARKER (24%), Carmel SEPULONI (7%) or Brendon BURNS (6%).

Effective party list for the Green party.

Effective party list for the Green party.

A vote for the Green party is a vote for David HAY (63%) or James SHAW (35%).

Effective party list for the ACT party.

Effective party list for the ACT party.

A vote for the ACT party is a vote for Don Brash (71%) or Catherine ISAAC (26%).

Effective party list for the Maori party.

Effective party list for the Maori party.

A vote for the Maori party is a wasted vote, in the sense that it will not help elect anybody to parliament because of the Maori party overhang.

Read Full Post »

Shown below are the updated Candidate Election Probabilities based on tonight’s polling update. Please click to embiggen. For an explanation of the methodology please see the original post on individual candidate election probabilities.

(Should also point out that I’ve made a couple of manual tweaks to the list this time, as it is the last one to be published before the election. I have given the Progressive party’s votes in Wigram to the Labour candidate, who is widely considered to be the most likely to benefit from Jim Anderton not standing, and have given votes to Hone Harawira in Te Tai Tokerau to reflect his likelihood of winning there.)

  1. Rank: From 0 to 899, gives the respective candidate’s relative likelihood of being elected, and is ordered firstly by probability to be elected, and then by party code and list ranking where there is a tie.  Candidates are shown in the table ordered by “rank”.
  2. Party Code : A unique code for each political party.  Parties are numbered 0~7, and ordered firstly by the number of seats won in the 2008 NZ General Election, and secondly by the number of party votes received.
  3. Party
  4. List Ranking
  5. Name: The name of the candidate (as given on the Elections New Zealand website, where available).
  6. Electorate: The electorate the candidate will stand in. For list-only candidates this will read “list only.”
  7. Electorate Code : A unique code for the electorate.  Electorates are numbered in alphabetical order, with general electorates (#0 ~ #62) preceding Maori electorates (#63 ~ #69). If the candidate is a list-only candidate candidate this code will take the value -1.
  8. Elect. 08: Blank, for the moment.
  9. Prob. Electorate: Probabilty of being elected to parliament as an electorate candidate.
  10. Prob. List: Probabilty of being elected to parliament as a list candidate.
  11. Prob. Combined: Combined probabilty of being elected to parliament as an electorate candidate.
  12. Prob. Last: Probabilty of being elected to parliament as the lowest ranked successful list candidate for their party.  In other words, the probability that a party vote for this party will go towards electing this candidate.
Probabilities for each candidate to be elected to Parliament

Probabilities for each candidate to be elected to Parliament through their electorate, through the party list, and the overall combined probability. (PNG, 760kB)

Read Full Post »

Shown below are the updated Candidate Election Probabilities based on tonight’s polling update. Please click to embiggen. For an explanation of the methodology please see the original post on individual candidate election probabilities.

Probabilities for each candidate to be elected to Parliament through their electorate, through the party list, and the overall combined probability.

Probabilities for each candidate to be elected to Parliament through their electorate, through the party list, and the overall combined probability. (PNG, 770kB)

Will follow tomorrow with some analysis, but for the mean time there are two points that stand out:

  1. With the number of recent polls the margins of error on the polling averages has shrunk, meaning there are less candidates on the above list.  There are only about 140 or so candidates with a chance of winning a seat, so if the polls are correct there won’t be too many surprises on election night.
  2. The results for Labour (but not so much for National) are heavily dependent on the electorate results, which aren’t necessarily modelled realistically given that National are polling so much higher than they were at either of the two previous general elections.  Many of Burns (#29, Christchurch Central), Tirikatene (#45, Te Tai Tonga), Hipkins (#42, Rimutaka), Lees-Galloway (#37, Palmerston North), Wood (#32, list only), Chadwick (#34, Rotorua), O’Conner (West Coast-Tasman, electorate only) and Sutton (#35, Waikato) are in for a disappointing night, but it’s difficult to tell exactly which at the moment.  For more info see Kiwiblog.

Will calculate the effective party lists tomorrow before the 12PM blackout, but for the moment they look as follows:

  1. National: Hayes (#64, Dunedin South), Hauiti (#63, Mangare), Collins (#66, Wigram)
  2. Labour: Nash (#27, Napier), Burns (#29, Christchurch Central), Mahuta-Coyle (#26, Tauranga)
  3. Green: Shaw (#15), Hay (#16)

Read Full Post »

There has been a bit of hysteria the last few days about dire consequences if New Zealand First should be returned to parliament. See PM John Key on Stuff, or the Vote For Change campaign’s highly ignorable press releases, for example.

So what’s going on? A couple of recent polls have the NZF party closing in on the 5% threshold, and the probability of NZF being returned to Parliament has shot up to about 50% on iPredict, from about 15% just over a week ago.

Probability of New Zealand First being returned to parliament according to iPredict, as of evening of 20 November, 2011.

Probability of New Zealand First being returned to parliament according to iPredict, as of evening of 20 November, 2011.

On top of this, NZF leader Winston Peters has made a point of saying he won’t go in to coalition with anybody, or support anybody with supply and confidence, leading observers to assume that if NZF wins seats in parliament this election everything will turn to custard and we will be having another election in the next few months.

So what would actually happen if NZF were returned to parliament?

The current situation.

To figure this out we run a series of simulations, firstly based on the current polling avereges. We call this “Situation #0”. It looks something like this:

Histogram showing the total number of seats National are expected to win in parliament under Situation #0. National are expected to win 65.4 +/- 0.8 (RMS) seats.

Histogram showing the total number of seats National are expected to win in parliament under Situation #0. National are expected to win 65.4 +/- 0.8 (RMS) seats.

Histogram showing the total number of seats Labour are expected to win in parliament under Situation #0.  Labour are expected to win 35.4 +/- 0.8 (RMS) seats.

Histogram showing the total number of seats Labour are expected to win in parliament under Situation #0. Labour are expected to win 35.4 +/- 0.8 (RMS) seats.

Keep in mind that a party would need 63 seats to win a majority:

Histogram showing the number of seats needed to form a majority in Parliament under Situation #0. The winning party or coalition will most probably need 63 seats in Parliament to form a majority.

Histogram showing the number of seats needed to form a majority in Parliament under Situation #0. The winning party or coalition will most probably need 63 seats in Parliament to form a majority.

So National is therefore almost guaranteed an outright majority in the house:

Scenario analysis for Situation #0. The bar graph shows the probabilities for different possible outcomes for a NZ General Election.  The National Party would have a roughly 99.98% chance of governing alone, a roughly 0.02% chance of governing as leader of a National-ACT coalition, and a 0% chance of governing as leader of a National-ACT-United Future coalition. There is a 0% chance that the Maori Party would hold the balance of power in Parliament.

Scenario analysis for Situation #0. The bar graph shows the probabilities for different possible outcomes for a NZ General Election. The National Party would have a roughly 99.98% chance of governing alone, a roughly 0.02% chance of governing as leader of a National-ACT coalition, and a 0% chance of governing as leader of a National-ACT-United Future coalition. There is a 0% chance that the Maori Party would hold the balance of power in Parliament.

So there you have it.

What if NZF makes 5%?

And what would happen if NZF just makes the 5% threshold? Firstly lets simulate this by assuming that NZF takes the same number of votes from National and Labour such that they get exactly 5%. We call this “Situation #1”. Under Situation #1 NZF would win exactly 6 seats. And the other parties?

Histogram showing the total number of seats National are expected to win in parliament under Situation #1. National are expected to win 62.1 +/- 0.8 (RMS) seats.

Histogram showing the total number of seats National are expected to win in parliament under Situation #1. National are expected to win 62.1 +/- 0.8 (RMS) seats.

Histogram showing the total number of seats Labour are expected to win in parliament under Situation #1. Labour are expected to win 33.2 +/- 0.8 (RMS) seats.

Histogram showing the total number of seats Labour are expected to win in parliament under Situation #1. Labour are expected to win 33.2 +/- 0.8 (RMS) seats.

So with NZF taking 1% or so of the vote from each of National and Labour and winning 6 seats, National and Labour would respectively be 3.3 and 2.2 seats worse off. The fallout is not just limited to those two parties either; the Greens, for example, would be 0.5 seats worse off. And who would form the government?

Scenario analysis for Situation #1. The bar graph shows the probabilities for different possible outcomes for a NZ General Election.  The National Party would have a roughly 25.1% chance of governing alone, a roughly 70.5% chance of governing as leader of a National-ACT coalition, and a roughly 4.1% chance of governing as leader of a National-ACT-United Future coalition. There is a 0.3% chance that the Maori Party would hold the balance of power in Parliament.

Scenario analysis for Situation #1. The bar graph shows the probabilities for different possible outcomes for a NZ General Election. The National Party would have a roughly 25.1% chance of governing alone, a roughly 70.5% chance of governing as leader of a National-ACT coalition, and a roughly 4.1% chance of governing as leader of a National-ACT-United Future coalition. There is a 0.3% chance that the Maori Party would hold the balance of power in Parliament.

So if NZF takes votes off National and Labour equally and makes the 5% threshold there is a much reduced chance of National getting a majority, but we would still have a National Prime Minister. Winston Peters wouldn’t be in a position to force another election.

What if the votes come exclusively from National?

And what would happen if NZF just makes the 5% threshold, and takes their extra votes exclusively from current National supporters. We call this “Situation #2”. Under Situation #2 NZF would still win exactly 6 seats, and National would be as follows:

Histogram showing the total number of seats National are expected to win in parliament under Situation #2. National are expected to win 61.2 +/- 0.8 (RMS) seats.

Histogram showing the total number of seats National are expected to win in parliament under Situation #2. National are expected to win 61.2 +/- 0.8 (RMS) seats.

Scenario analysis for Situation #2. The bar graph shows the probabilities for different possible outcomes for a NZ General Election. The National Party would have a roughly 4.4% chance of governing alone, a roughly 69.6% chance of governing as leader of a National-ACT coalition, and a roughly 21.1% chance of governing as leader of a National-ACT-United Future coalition. There is a roughly 5.0% chance that the Maori Party would hold the balance of power in Parliament (with a National-coalition advantage).

So if NZF takes votes solely off National and just makes the 5% threshold there is a much reduced chance of National getting a majority, but we would still most likely get a National Prime Minister, even without taking the Maori Party into consideration. Winston Peters almost certainly wouldn’t be in a position to force another election.

What if NZF makes 7%, and the votes come exclusively from National?

Now lets assume that NZF wins exactly 7% of the vote, with their extra votes coming exclusively from current National supporters. We call this “Situation #3”. Under Situation #3 the results would be as follows:

Histogram showing the total number of seats NZF are expected to win in parliament under Situation #3. NZF are now expected to win 8.7 +/- 0.4 (RMS) seats.

Histogram showing the total number of seats NZF are expected to win in parliament under Situation #3. NZF are now expected to win 8.7 +/- 0.4 (RMS) seats.

Histogram showing the total number of seats National are expected to win in parliament under Situation #3. National are expected to win 58.6 +/- 0.7 (RMS) seats.

Histogram showing the total number of seats National are expected to win in parliament under Situation #3. National are expected to win 58.6 +/- 0.7 (RMS) seats.

Scenario analysis for Situation #3. The bar graph shows the probabilities for different possible outcomes for a NZ General Election.  The National Party would have a 0% chance of governing alone, a roughly 0.4% chance of governing as leader of a National-ACT coalition, and a roughly 4.5% chance of governing as leader of a National-ACT-United Future coalition. There is a roughly 95.5% chance that the Maori Party would hold the balance of power in Parliament (still most likely with a National-coalition advantage).

Scenario analysis for Situation #3. The bar graph shows the probabilities for different possible outcomes for a NZ General Election. The National Party would have a 0% chance of governing alone, a roughly 0.4% chance of governing as leader of a National-ACT coalition, and a roughly 4.5% chance of governing as leader of a National-ACT-United Future coalition. There is a roughly 95.5% chance that the Maori Party would hold the balance of power in Parliament (still most likely with a National-coalition advantage).

So even under the rediculously optimistic scenario of NZF doubling their current support in the next six days, with the new support coming solely off National, the Maori party would still most-likely hold the balance of power in parliament.

And what would the Maori party do? Coalition with National, ACT and United Future? Or coalition with Labour, Greens, Mana and New Zealand First? Even assuming that the latter four parties were all on the same page (unfeasible, given recent statements from their leaders), would the Maori party favour them? Not likely if a three-party right-wing coalition had a numbers advantage over the four-party left-wing coalition. It would be far too easy (politically) for the Maori Party to go into a right-wing coalition, and extract some fairly heavy concessions whilst doing so.

Conclusion.

So, in summary, even if NZF win 7% of the vote, which is unlikely on current polling, the chances of them holding a balance of power and forcing another election are effectively zero. Anybody who suggests otherwise is just being a bit hysterical.

Read Full Post »

When I started the blog a couple of years ago I sort of promised to write a series of posts on how the simulation works so that others could replicate the results, if need be. Unfortunately gainful employment has interfered, and one week out from the election there is no way I will get this finished. Still, better late than never.

While there is a bit of maths going on behind the scenes, the general principle is surprisingly simple: average all available NZ political polls, and then run a Monte Carlo Simulation to get all the interesting information we need to make the graphs. This process is summarised in the schematic below:

General overview of poll averaging and election simulation.

General overview of poll averaging and election simulation.

The process can be divided up in to 3 main steps:

  1. Polling information (red): Moving averages of the political polls and information regarding electorate swings are calculated from the input polls and the results of the 2005 and 2008 General Elections. (NB, this information, along with the party lists in step 3, is the only information that goes in to the calculations.)
  2. Election simulation (blue): Using the Monte Carlo method, running on a standard laptop with a standard pseudo-random number generator, an election is simulated, based on the polling averages and electorate swings calculated in step 1.
  3. Scenario analysis (green): Using the simulated election results from step 2, we look at the party lists and figure out who gets in to parliament.  We then look at any other result that may be of interest.  Normally this would be the number of seats won be each party, which parties will form a coalition and so on, but in theory, if the simulation in step 2 is working correctly, it can be anything you may be interested in looking at after a real election.  For example, if you wanted to, you could look at the number of women candidates winning a South Island electorate seat.

Of course, depending on the pseudo-random numbers dished up in step 2 you may get a relatively unlikely result: perhaps based on current polling your simulation gives National 47% of the vote, Labour 32%, Greens get 14%, and New Zealand First 5%.  This is possible, but not the most probable outcome.  To make sure the results are realistic we simply repeat steps 2 and 3 a large number of times, and keep a running total for each variable or outcome we are interested in measuring.  By doing this any unlikely statistical fluctuations should cancel each other out, and we can get a meaningful measurement of the numbers we are interested in.

Typically steps 2 and 3 are repeated 50,000 times for each day we simulate an election for, which takes about a minute or so of computer time.  To get the time series graphs, we have to do these simulaitons for each day we are interested in, although normally they are just run for the last couple of hundred days to update any recent movement, such as the Scenario Analysis time series graph, for example (scroll down to “Scenario Analysis”).

Each time we complete step 3, we update a running total of the variables we are interested in (number of seats won by National, number of women candidates winning a South Island electorate seat, etc.) and also the variables-squared (number of seats won by National squared, number of women candidates winning a South Island electorate seat squared, etc.). We then divide by the total number of simulations (say, 50,000) and that gives the expected values and expected value-squareds. For example, in yesterdays simulations the National party won 3,270,000 seats, and dividing by 50,000 gives an expected value of 65.4 seats. A bit of seventh-form stats gives the root mean square (RMS) error on the expected value, and that is how we get the final value of 65.4 +/- 0.8 seats for National (scroll down to “Seats in Parliament”).

That’s all there is to it. The calculations for the poll averaging and the simulation get a bit more involved, although probably not much harder than a first-year uni level maths course, but the general principle of the calculation should be surprisingly simple.

Read Full Post »

There has been a bit of talk lately about tactical voting in Epsom, and the “cup of tea” between PM John Key and ACT Epsom candidate John Banks has been in the news a bit.  So what’s going on?

The short version of the story is that in New Zealand, where we elect our Parliament under MMP, a party needs to either win 5% of the nationwide popular vote (party vote) or win an electorate seat to get seats in Parliament in proportion to their party vote. The current National party government’s coalition partner, the ACT party, won’t make the 5% threshold on current polling, and so the PM is in a position where he is motivated to throw the ACT party an electorate seat, the seat of Epsom to be precise.

So what happens if ACT do win Epsom?

Total seats won by ACT party, assuming they win Epsom.

Total seats won by the ACT party, assuming ACT win Epsom.

Total seats won by National party, assuming ACT win Epsom.

Total seats won by the National party, assuming ACT win Epsom.

This is the more likely situation at the moment: ACT win 1 electorate and 2.0 +/- 0.1 (RMS) total seats in Parliament. Under this scenario the National party would win 65.4 +-/ 0.8 (RMS) seats in parliament.

And what happens if ACT don’t win Epsom, and the National party candidate (Paul Goldsmith) wins instead?

Total seats won by ACT party, assuming National win Epsom.

Total seats won by the ACT party, assuming National win Epsom.

Total seats won by the National party, assuming National win Epsom.

Total seats won by the the National party, assuming National win Epsom.

In this situation the ACT party gets no seats in Parliament, and is 2.0 +/- 0.1 seats worse off. The plus-side for National is that they win 66.5 +/- 0.8 seats, and are now 1.1 seats better off.

You can do similar calculations for the other parties.  Here’s how everybody ends up if National win Epsom, relative to how they would have been if ACT had won Epsom:

  • National: +1 electorate seat, +0.1 list seats.  Overall +1.1 seats better off.
  • Labour: +0.6 seats.
  • Green: +0.3 seats.
  • ACT: -2.0 seats.
  • Maori: +0.0 seats.
  • NZF: +0.0 seats.
  • Overhang: +0.0 seats in Parliament.
  • (NB: rounding)

For those who wonder why Labour only gets 0.6 extra seats, vs. National’s 1.1, the answer is simple: Labour is polling just over half what National is polling in terms of the party vote. Regardless, if you ignore the probability of ACT going into coalition with Labour, Labour are still better off if National win Epsom than they are if ACT win Epsom.

This raises interesting questions regarding tactical voting for those in the Epsom electorate. Assuming that ACT will not hold a balance of power after the election and choose to go in to coalition with Labour, then Labour are better off if Paul Goldsmith (National candidate for Epsom) wins the seat, and John Banks (the ACT candidate) loses. Similar logic applies for the Greens, Mana, and NZF. ACT supporters obviously want their candidate to win. For Maori, United Future and National supporters the situation is a bit more complex, and depends on who is likely to win the election.

For that, please refer to the scenario analysis graphs below:

Scenario analysis for the most recent election simulation assuming ACT win Epsom.

Scenario analysis for the most recent election simulation assuming ACT win Epsom.

Total seats won by the the National party, assuming National win Epsom.

Total seats won by the the National party, assuming National win Epsom.

Looking at the two graphs, you might not notice too much difference. The first graph shows National with a 99.98% chance of winning a majority, and a 0.02% chaince of leading a National-ACT coalition. The second shows National with a 100.00% chance of winning an absolute majority, and a 0.00% chance of leading a National-ACT coalition. Either way, New Zealand gets a National Party Prime Minster.

So if you are a National, Maori or United Future party supporter, what is your preferred result? Based on current polling it would be option #2 above: National win Epsom.

(I should here point out the difference between tactics and strategy. On this blog, “tactics” refers to the short term: doing what is necessary to get the result you want from the next election. “Strategy” refers to a more long-term positional advantage. Pollsters are not in a position to comment on whether having ACT in Parliament would be good or bad for National, Maori and United Future supporters in the long term.)

The results of this hypothetical analysis are surprisingly simple: Labour, Green, Mana and New Zealand First supporters in Epsom, and an overwhelming majority of National, Maori and United Future supporters in Epsom should vote tactically for Paul Goldsmith. The National candidate should win in a landslide.

Read Full Post »

Older Posts »