Update: Forgot to mention the source of this data:  Abacus.  Poll date: August 31, 2015.  Map colours also updated to make things easier to understand, and added an additional map. (September 5, 2015)  Note to mobile users:  This program isn’t perfect for you, yet; but I will be adding that functionality in due time.

I have been a little less active of late.  Not because I’ve taken time off from blogging – though, being “Occasionally Prolific”, that does happen from time to time, but, rather, because I was wanting to provide some more detailed and graphical information along with my seat projections.

To that end, I went looking for a plugin that would enable me to display an interactive map of some kind on my website here, without needing to harness Google Maps or some other map server.  Those services are great, but for what I am attempting to do, they didn’t work for me.

After some time of searching, I came up empty-handed.

So,  instead, I wrote one.

I sat down at my computer, and wrote a jQuery/JavaScript/PHP plugin that did what I needed it to do.  And, much to my own personal satisfaction, it works.

What I wanted to do is produce something that would display the 338 ridings that are up for grabs, while,  just as importantly, enable you to navigate around the country, see the various results for each individual riding.

It then occurred to me that because a poll isn’t exact (in that there is always a margin of error), it would make sense to work out, based on the poll, just how confident I am in each riding’s result.  That took an entire afternoon of cruising around the internet, teaching myself statistical math I had never studied in university, working out things such as variances, standard deviations, probability densities, cumulative probabilities, and so on.

Of course, the formulas I needed weren’t actually readily available, but, because I’m a geektm, I found the equation for a normal distribution, determined how I needed to manipulate the algebra to isolate the appropriate variable, plugged the formulas into my trusty Prediction Machine (which is a black box device with a “patented” projection algorithm of my own design.  Don’t worry, it’s not that exciting.), and turned it on.

The results were surprising.  And it worked.

Basically, the “confidence” of any given result is a measure of the amount of overlap between the first and second place projected candidate.  If, for example, the margin of error is +/- 10%, and Candidate A evaluates to having 40% support, while candidate B evaluates to 35% support, then, according to most polls, Candidate A’s support is between 30 and 50%, 95% of the time.  (Which is the same as saying +/- 10%, 19 times out of 20.)  Candidate B’s support is therefore the same kind of thing: 25% to 45%, 95% of the time.

So there’s an overlap between Candidate A and B in this case, and, because of that, we can’t be sure that Candidate A would actually win based on this poll.  (NOTE: This is still based on the poll, not the election.)  The more overlap there is, the less confident we can be in the result.

On the map, I have adjusted the colours of the constituencies based on this confidence value.  As the confidence decreases, the colour becomes less vibrant (or saturated).   (Figuring out how to do that mathematically also took some doing, because you can’t simply mix RGB values and get the result you want.)

Okay, enough of telling you what I’ve done, now let’s get to the numbers:

First,  a look at the number of seats that I can be sure that, based on this poll, would be taken by each party.  This occurs when the Maximum possible value of the second-placed candidate is less than the lowest possible value of the winner.

[visualizer id=”1790″]

The second graph shows the number of likely seats, where I am less sure that the winner would actually take the seat.  (See above)

[visualizer id=”1792″]

Which, of course, brings us to this – the projected result.  Bottom line  is, at this point in the campaign, an outright majority for Tom Mulcair seems highly unlikely.  What seems equally unlikely is Justin Trudeau stands any chance of passing him.  It is very likely that the Conservatives will retain the largest caucus in the House.  I’m not ready yet to call a Conservative majority or minority one way or the other yet, because anything can happen.  There’s a lot of campaign still to come, so we’ll have to keep a close eye on things.

[visualizer id=”1793″]

And here is the map:

[scb_map pollster=”Abacus” polldate=”20150831″ datafile=”PollResults.csv”  basemap=”Canada” htmlpath=”Canada.Fed.Constituencies.English.Only” mainmap=”projected winners” underlyingmap=”incumbents” underlyingfolder=”Incumbents” altmap=”popular support” altfolder=”Popular.Support”]

To move around, click on a region.  The map will update.  Use the arrows that appear to navigate within the region, or to return to the next higher level.  When you get close enough in, you can look at each individual riding’s projected results.  There are three maps:  The projected results, the incumbents, and the “popular support” map.  This third map shows a “mix” of the party colours based on the popular support each party will theoretically receive should an election reflect this poll.  Click on the grey area on the right hand side of the map to rotate through the different maps.

3 Replies

  1. What poll did you use for your data? As well, did you cross reference polls to justify the headline? I didn’t come across any named polls or links in the post.

Leave a Reply

Your email address will not be published. Required fields are marked *