Pages

Tuesday, June 28, 2016

Monte Carlo Simulation of Poll Results

I have brought together some disparate data so that I can use Monte Carlo techniques to simulate an election outcome (1,000,000 times) from yesterday's poll aggregation result (51.6 per cent in the Coalition's favour).

The first step was to establish the state and national starting points (ie. the TPP results from the 2013 election). For this data, I went to the AEC: http://results.aec.gov.au/17496/Website/HouseTppByState-17496.htm.

The national swing is the latest poll aggregation minus the 2013 TPP result. A negative result means a swing to Labor. A positive result is a swing to the Coalition.

To establish the relative swings in each state, I used the latest Newspoll results for June in today's Australian and compared them with the Newspoll national swing since the 2013 election. The relative swings (in percentage points) I calculated were as follows. These are added to the national swing. A negative relative swing moves a state more to Labor than the national swing. A positive swing moves a state less to Labor than the national swing.

NSW VIC QLD WA SA TAS ACT NT
0 -0.1 1.7 -2.5 -0.8 2.5 0 0 0

These swings were applied to the pendulum from the 2013 election, as adjusted for the new electoral boundaries. I used Antony Green's pendulum. The results were converted into a probability of a Coalition or Labor victory. The conversion used a cumulative density function from scipy.stats, with a standard deviation of 2.7 percentage points.

This approach did not work for all seats. It did not work for seats where an independent had won in 2013. Nor did it work for seats where independents, the Greens or Xenophon might win in 2016. For the following set of seats I substituted the poll derived probability with a betting market probability, adjusted for the longshot bias: Melbourne (VIC), Denison (TAS), Indi (VIC), Kennedy (QLD), Fairfax (QLD), Cowper (NSW), New England (NSW), Barker (SA), Boothby (SA), Grey (SA), Mayo (SA) and Batman (VIC).

From here I applied a Monte Carlo simulation for 1,000,000 iterations. With the usual caveats that go with code that has been slapped together in an hour and a half (ie. these results could be completely bogus and riddled with human error), the results of the simulation were as follows. The most likely seat outcome is 79 seats for the Coalition, 65 for Labor, and 6 others. The Coalition has an 87.7 per cent chance of forming majority government.



The seat probabilities I used for this Monte Carlo simulation are as follows.

Any Other Coalition Green Ind Katter Labor NXT
Seat
Mallee (VIC) 0 1.000000e+00 0.000000 0.000000 0 0.000000e+00 0.000000
Maranoa (QLD) 0 1.000000e+00 0.000000 0.000000 0 1.812495e-11 0.000000
Farrer (NSW) 0 1.000000e+00 0.000000 0.000000 0 1.217915e-13 0.000000
Mitchell (NSW) 0 1.000000e+00 0.000000 0.000000 0 3.635980e-13 0.000000
Bradfield (NSW) 0 1.000000e+00 0.000000 0.000000 0 1.384115e-12 0.000000
Murray (VIC) 0 1.000000e+00 0.000000 0.000000 0 9.658940e-15 0.000000
Parkes (NSW) 0 1.000000e+00 0.000000 0.000000 0 1.812495e-11 0.000000
Berowra (NSW) 0 1.000000e+00 0.000000 0.000000 0 1.635948e-10 0.000000
Riverina (NSW) 0 1.000000e+00 0.000000 0.000000 0 1.635948e-10 0.000000
Wentworth (NSW) 0 1.000000e+00 0.000000 0.000000 0 2.075012e-10 0.000000
Mackellar (NSW) 0 1.000000e+00 0.000000 0.000000 0 2.628390e-10 0.000000
Curtin (WA) 0 1.000000e+00 0.000000 0.000000 0 5.028657e-09 0.000000
Moncrieff (QLD) 0 9.999997e-01 0.000000 0.000000 0 2.503352e-07 0.000000
Groom (QLD) 0 9.999961e-01 0.000000 0.000000 0 3.901843e-06 0.000000
Cook (NSW) 0 9.999998e-01 0.000000 0.000000 0 1.697103e-07 0.000000
Gippsland (VIC) 0 1.000000e+00 0.000000 0.000000 0 4.039625e-09 0.000000
North Sydney (NSW) 0 9.999998e-01 0.000000 0.000000 0 2.062545e-07 0.000000
O'Connor (WA) 0 9.999984e-01 0.000000 0.000000 0 1.614523e-06 0.000000
Warringah (NSW) 0 9.999996e-01 0.000000 0.000000 0 4.440377e-07 0.000000
Durack (WA) 0 9.999981e-01 0.000000 0.000000 0 1.931239e-06 0.000000
Calare (NSW) 0 9.999992e-01 0.000000 0.000000 0 7.782812e-07 0.000000
Menzies (VIC) 0 9.999999e-01 0.000000 0.000000 0 6.274431e-08 0.000000
Fadden (QLD) 0 9.998891e-01 0.000000 0.000000 0 1.109331e-04 0.000000
Forrest (WA) 0 9.999850e-01 0.000000 0.000000 0 1.495149e-05 0.000000
Hume (NSW) 0 9.999909e-01 0.000000 0.000000 0 9.124021e-06 0.000000
Lyne (NSW) 0 9.999909e-01 0.000000 0.000000 0 9.124021e-06 0.000000
Wide Bay (QLD) 0 9.994195e-01 0.000000 0.000000 0 5.805289e-04 0.000000
McPherson (QLD) 0 9.992488e-01 0.000000 0.000000 0 7.512405e-04 0.000000
Tangney (WA) 0 9.999288e-01 0.000000 0.000000 0 7.123697e-05 0.000000
Moore (WA) 0 9.998293e-01 0.000000 0.000000 0 1.707408e-04 0.000000
Flinders (VIC) 0 9.999909e-01 0.000000 0.000000 0 9.124021e-06 0.000000
Hughes (NSW) 0 9.998519e-01 0.000000 0.000000 0 1.480729e-04 0.000000
McMillan (VIC) 0 9.999909e-01 0.000000 0.000000 0 9.124021e-06 0.000000
Wright (QLD) 0 9.968310e-01 0.000000 0.000000 0 3.169028e-03 0.000000
Canning (WA) 0 9.992488e-01 0.000000 0.000000 0 7.512405e-04 0.000000
Kooyong (VIC) 0 9.999716e-01 0.000000 0.000000 0 2.836012e-05 0.000000
Goldstein (VIC) 0 9.999668e-01 0.000000 0.000000 0 3.317359e-05 0.000000
Sturt (SA) 0 9.999612e-01 0.000000 0.000000 0 3.875334e-05 0.000000
Wannon (VIC) 0 9.998718e-01 0.000000 0.000000 0 1.282479e-04 0.000000
Higgins (VIC) 0 9.998293e-01 0.000000 0.000000 0 1.707408e-04 0.000000
Fisher (QLD) 0 9.766504e-01 0.000000 0.000000 0 2.334957e-02 0.000000
Pearce (WA) 0 9.925224e-01 0.000000 0.000000 0 7.477578e-03 0.000000
Hinkler (QLD) 0 9.547458e-01 0.000000 0.000000 0 4.525416e-02 0.000000
Stirling (WA) 0 9.898930e-01 0.000000 0.000000 0 1.010699e-02 0.000000
Bowman (QLD) 0 9.511072e-01 0.000000 0.000000 0 4.889277e-02 0.000000
Ryan (QLD) 0 9.341635e-01 0.000000 0.000000 0 6.583650e-02 0.000000
Aston (VIC) 0 9.984213e-01 0.000000 0.000000 0 1.578708e-03 0.000000
Bennelong (NSW) 0 9.837078e-01 0.000000 0.000000 0 1.629221e-02 0.000000
Dawson (QLD) 0 8.798433e-01 0.000000 0.000000 0 1.201567e-01 0.000000
Swan (WA) 0 9.547458e-01 0.000000 0.000000 0 4.525416e-02 0.000000
Casey (VIC) 0 9.950830e-01 0.000000 0.000000 0 4.917013e-03 0.000000
Longman (QLD) 0 8.198897e-01 0.000000 0.000000 0 1.801103e-01 0.000000
Dickson (QLD) 0 7.997898e-01 0.000000 0.000000 0 2.002102e-01 0.000000
Flynn (QLD) 0 7.783987e-01 0.000000 0.000000 0 2.216013e-01 0.000000
Herbert (QLD) 0 7.439867e-01 0.000000 0.000000 0 2.560133e-01 0.000000
Burt (WA) 0 8.940354e-01 0.000000 0.000000 0 1.059646e-01 0.000000
Hasluck (WA) 0 8.870985e-01 0.000000 0.000000 0 1.129015e-01 0.000000
Leichhardt (QLD) 0 6.810012e-01 0.000000 0.000000 0 3.189988e-01 0.000000
Dunkley (VIC) 0 9.766504e-01 0.000000 0.000000 0 2.334957e-02 0.000000
Cowan (WA) 0 7.439867e-01 0.000000 0.000000 0 2.560133e-01 0.000000
Macquarie (NSW) 0 8.198897e-01 0.000000 0.000000 0 1.801103e-01 0.000000
Forde (QLD) 0 4.956192e-01 0.000000 0.000000 0 5.043808e-01 0.000000
Brisbane (QLD) 0 4.808508e-01 0.000000 0.000000 0 5.191492e-01 0.000000
Bass (TAS) 0 7.783987e-01 0.000000 0.000000 0 2.216013e-01 0.000000
La Trobe (Vic) 0 9.187069e-01 0.000000 0.000000 0 8.129310e-02 0.000000
Corangamite (VIC) 0 9.129883e-01 0.000000 0.000000 0 8.701166e-02 0.000000
Gilmore (NSW) 0 7.439867e-01 0.000000 0.000000 0 2.560133e-01 0.000000
Bonner (QLD) 0 3.934876e-01 0.000000 0.000000 0 6.065124e-01 0.000000
Reid (NSW) 0 6.941110e-01 0.000000 0.000000 0 3.058890e-01 0.000000
Macarthur (NSW) 0 6.810012e-01 0.000000 0.000000 0 3.189988e-01 0.000000
Deakin (VIC) 0 8.643622e-01 0.000000 0.000000 0 1.356378e-01 0.000000
Page (NSW) 0 6.541047e-01 0.000000 0.000000 0 3.458953e-01 0.000000
Robertson (NSW) 0 6.541047e-01 0.000000 0.000000 0 3.458953e-01 0.000000
Lindsay (NSW) 0 6.403480e-01 0.000000 0.000000 0 3.596520e-01 0.000000
Eden Monaro (NSW) 0 6.264070e-01 0.000000 0.000000 0 3.735930e-01 0.000000
Banks (NSW) 0 5.836504e-01 0.000000 0.000000 0 4.163496e-01 0.000000
Braddon (TAS) 0 5.980403e-01 0.000000 0.000000 0 4.019597e-01 0.000000
Hindmarsh (SA) 0 8.198897e-01 0.000000 0.000000 0 1.801103e-01 0.000000
Solomon (NT) 0 4.222399e-01 0.000000 0.000000 0 5.777601e-01 0.000000
Lyons (TAS) 0 3.934876e-01 0.000000 0.000000 0 6.065124e-01 0.000000
Capricornia (QLD) 0 8.942334e-02 0.000000 0.000000 0 9.105767e-01 0.000000
Petrie (QLD) 0 7.277572e-02 0.000000 0.000000 0 9.272243e-01 0.000000
Dobell (NSW) 0 2.044599e-01 0.000000 0.000000 0 7.955401e-01 0.000000
McEwen (VIC) 0 4.367835e-01 0.000000 0.000000 0 5.632165e-01 0.000000
Paterson (NSW) 0 1.840947e-01 0.000000 0.000000 0 8.159053e-01 0.000000
Lingiari (NT) 0 1.473151e-01 0.000000 0.000000 0 8.526849e-01 0.000000
Bendigo (VIC) 0 2.855145e-01 0.000000 0.000000 0 7.144855e-01 0.000000
Lilley (QLD) 0 1.691499e-02 0.000000 0.000000 0 9.830850e-01 0.000000
Parramatta (NSW) 0 1.087499e-01 0.000000 0.000000 0 8.912501e-01 0.000000
Chisholm (VIC) 0 2.489975e-01 0.000000 0.000000 0 7.510025e-01 0.000000
Moreton (QLD) 0 1.276776e-02 0.000000 0.000000 0 9.872322e-01 0.000000
Richmond (NSW) 0 8.942334e-02 0.000000 0.000000 0 9.105767e-01 0.000000
Bruce (VIC) 0 2.261091e-01 0.000000 0.000000 0 7.738909e-01 0.000000
Perth (WA) 0 3.394049e-02 0.000000 0.000000 0 9.660595e-01 0.000000
Kingsford Smith (NSW) 0 3.991081e-02 0.000000 0.000000 0 9.600892e-01 0.000000
Greenway (NSW) 0 3.124287e-02 0.000000 0.000000 0 9.687571e-01 0.000000
Griffith (QLD) 0 2.964141e-03 0.000000 0.000000 0 9.970359e-01 0.000000
Jagajaga (VIC) 0 1.087499e-01 0.000000 0.000000 0 8.912501e-01 0.000000
Wakefield (SA) 0 1.473151e-01 0.000000 0.000000 0 8.526849e-01 0.000000
Melbourne Ports (VIC) 0 7.803866e-02 0.000000 0.000000 0 9.219613e-01 0.000000
Brand (WA) 0 8.624619e-03 0.000000 0.000000 0 9.913754e-01 0.000000
Oxley (QLD) 0 1.151779e-03 0.000000 0.000000 0 9.988482e-01 0.000000
Isaacs (VIC) 0 6.307030e-02 0.000000 0.000000 0 9.369297e-01 0.000000
Adelaide (SA) 0 1.019995e-01 0.000000 0.000000 0 8.980005e-01 0.000000
Barton (NSW) 0 8.624619e-03 0.000000 0.000000 0 9.913754e-01 0.000000
McMahon (NSW) 0 7.035892e-03 0.000000 0.000000 0 9.929641e-01 0.000000
Rankin (QLD) 0 3.149654e-04 0.000000 0.000000 0 9.996850e-01 0.000000
Ballarat (VIC) 0 2.872508e-02 0.000000 0.000000 0 9.712749e-01 0.000000
Franklin (TAS) 0 4.612869e-03 0.000000 0.000000 0 9.953871e-01 0.000000
Makin (SA) 0 4.670792e-02 0.000000 0.000000 0 9.532921e-01 0.000000
Blair (QLD) 0 1.569357e-04 0.000000 0.000000 0 9.998431e-01 0.000000
Fremantle (WA) 0 1.302025e-03 0.000000 0.000000 0 9.986980e-01 0.000000
Hunter (NSW) 0 2.099358e-03 0.000000 0.000000 0 9.979006e-01 0.000000
Werriwa (NSW) 0 7.912060e-04 0.000000 0.000000 0 9.992088e-01 0.000000
Whitlam (NSW) 0 4.710375e-04 0.000000 0.000000 0 9.995290e-01 0.000000
Hotham (VIC) 0 2.645521e-03 0.000000 0.000000 0 9.973545e-01 0.000000
Canberra (ACT) 0 2.747123e-04 0.000000 0.000000 0 9.997253e-01 0.000000
Shortland (NSW) 0 2.392942e-04 0.000000 0.000000 0 9.997607e-01 0.000000
Corio (VIC) 0 1.469993e-03 0.000000 0.000000 0 9.985300e-01 0.000000
Watson (NSW) 0 2.582655e-05 0.000000 0.000000 0 9.999742e-01 0.000000
Holt (VIC) 0 2.747123e-04 0.000000 0.000000 0 9.997253e-01 0.000000
Newcastle (NSW) 0 1.151929e-05 0.000000 0.000000 0 9.999885e-01 0.000000
Kingston (SA) 0 3.606509e-04 0.000000 0.000000 0 9.996393e-01 0.000000
Chifley (NSW) 0 8.390792e-07 0.000000 0.000000 0 9.999992e-01 0.000000
Blaxland (NSW) 0 4.795001e-07 0.000000 0.000000 0 9.999995e-01 0.000000
Cunningham (NSW) 0 3.968561e-07 0.000000 0.000000 0 9.999996e-01 0.000000
Maribyrnong (VIC) 0 8.263808e-06 0.000000 0.000000 0 9.999917e-01 0.000000
Lalor (VIC) 0 2.076509e-06 0.000000 0.000000 0 9.999979e-01 0.000000
Fenner (ACT) 0 4.537991e-08 0.000000 0.000000 0 1.000000e+00 0.000000
Fowler (NSW) 0 1.605726e-08 0.000000 0.000000 0 1.000000e+00 0.000000
Sydney (NSW) 0 1.605726e-08 0.000000 0.000000 0 1.000000e+00 0.000000
Calwell (VIC) 0 8.329858e-08 0.000000 0.000000 0 9.999999e-01 0.000000
Port Adelaide (SA) 0 3.280209e-07 0.000000 0.000000 0 9.999997e-01 0.000000
Scullin (VIC) 0 3.006928e-08 0.000000 0.000000 0 1.000000e+00 0.000000
Gorton (VIC) 0 7.331915e-10 0.000000 0.000000 0 1.000000e+00 0.000000
Gellibrand (VIC) 0 2.892747e-10 0.000000 0.000000 0 1.000000e+00 0.000000
Grayndler (NSW) 0 6.064071e-15 0.000000 0.000000 0 1.000000e+00 0.000000
Wills (VIC) 0 3.383526e-15 0.000000 0.000000 0 1.000000e+00 0.000000
Melbourne (VIC) 0 0.000000e+00 1.000000 0.000000 0 0.000000e+00 0.000000
Denison (TAS) 0 0.000000e+00 0.000000 1.000000 0 0.000000e+00 0.000000
Indi (VIC) 0 1.843175e-01 0.000000 0.815683 0 0.000000e+00 0.000000
Kennedy (QLD) 0 0.000000e+00 0.000000 0.000000 1 0.000000e+00 0.000000
Fairfax (QLD) 0 1.000000e+00 0.000000 0.000000 0 0.000000e+00 0.000000
Cowper (NSW) 0 6.626480e-01 0.000000 0.337352 0 0.000000e+00 0.000000
New England (NSW) 0 7.392168e-01 0.000000 0.260783 0 0.000000e+00 0.000000
Barker (SA) 0 6.896515e-01 0.000000 0.000000 0 0.000000e+00 0.310349
Boothby (SA) 0 7.748514e-01 0.000000 0.000000 0 0.000000e+00 0.225149
Grey (SA) 0 6.626690e-01 0.000000 0.000000 0 0.000000e+00 0.337331
Mayo (SA) 0 3.749866e-01 0.000000 0.000000 0 0.000000e+00 0.625013
Batman (VIC) 0 0.000000e+00 0.419907 0.000000 0 5.800931e-01 0.000000

PS: if these results are bogus and riddled with human error, please let me know so that I can fix them. Thank you.

No comments:

Post a Comment