Thursday, June 25, 2015

City Council Analysis

Back after the 2013 Edmonton municipal election, I did a quick analysis to see if I could predict who some of the new mayor Don Iveson's friends on council would be. My thought was that councillors with similar platforms to the mayor's, and who are potentially more likely to agree with him on votes, were also likely to get voter support in the same neighborhoods due to their similarity. It seemed plausible enough so I did a correlation analysis.

It's now been a decent enough time since the last election that I've decided to check if my guess was accurate or not. Let's take a look!

Edmonton's Open Data has a log of the voting record for the 2013-2017 council, and it is fairly long. All told, there were 2,757 different motions that had been voted on so far. One issue with taking a look at all of these combined is that plenty of the votes are for procedural matters in council that get passed quickly and unanimously, and they're kinda boring from an analysis point of view. Of the 2,757 motions that have been voted on, 2,611 were unanimous one way or another. So let's ignore those, and focus on the remaining 146 contentious votes.

If we compare how each councillor and the mayor voted for every contentious vote they were present for, we can see how often any given pair end up voting the same way. The end results look like this:

(Click to zoom and enhance)
One of the first things to notice is that mayor Iveson does seem to have a fair bit of support on council - 7 councillors tend to vote the same way he does more than 80% of the time, and that's enough for a majority on most votes. These same 7 councillors (Knack, Esslinger, Henderson, Walters, Sohi, McKeen, and Loken) all tend to agree very consistently with each other too (with the possible exception of councillors McKeen and Loken). I wouldn't go so far as to say that they act as a voting block, but there certainly is evidence that they get along very well professionally, to say the least.

Other interesting observations include that councillors Loken, Caterina, and Gibbons all vote together quite a bit, with councillors Caterina and Gibbons agreeing more with each other than with the mayor. Councillors Anderson and Nickel quite clearly do not see eye-to-eye with most of the rest of their council colleagues.

One way we can check out my previous analysis is to compare the frequency councillors agree with the mayor with the correlation values I had previously obtained. If we do that, we can generate a graph like this:


Back when I did the original analysis, plenty of people (including myself) were surprised at the fact that councillor Walters ranked so low on the list. It turns out they were surprised with good reason, as he is one of the most notable outliers on the graph. It looks as though the analysis was alright, but nothing to be proud of. It is perhaps better than a random guess, but not necessarily something that provides critical or accurate insight immediately following an election.

One last graph for you. Each member of council had a fellow councillor who they tended to agree with the most. If we pretend that this coincides with who influences who, we can draw a graph like this:

This shows that for seven councillors, the person they agree with the most is mayor Iveson. The remaining councillors tend to split off in a group where they agree with the Caterina/Gibbons group that I mentioned above, though the frequency with which they agree with either of those two councillors is significantly lower than how often the rest tend to agree with the mayor.

The results from this analysis could exist due to a large number of different reasons. It's possible, for example, that this is an example of mayor Iveson's abilities to gain support from his councillors, and it's equally possible that it shows his ability to listen and accommodate the views of his councillors. Either way, it is his job to be the leader of city council, and so far the data seems to suggest he's doing just that.

Monday, June 8, 2015

NHL Odds in a Best-of-7 Series

Last year, Andrew and I worked together to look at which NHL playoff game was the most critical to victory in an NHL series. He built such a lovely database of playoff series that I just couldn't pass up the opportunity to take another look at the problem.

Before looking at real-world results, though, let's take a look at what the most important game ought to be in a perfectly even scenario. It's relatively simple to take a look at how a best-of-seven playoff series will turn out, and a Markov chain for a series will look like this:


Here you can see how each team's odds of winning the series go up or down based on how each previous game has gone. For example, if a team is leading 2 games to 1, their odds of winning the series are 69%. One important thing to note is that in this case it doesn't matter how they got there - there are three ways for a given team to get to a series score of 2-1 (count the lines if you'd like!), and they all lead to the same probability of winning the series. Also, note the symmetry in the diagram, since this model assumes both teams are perfectly even.

At this point, asking which game is most important to win becomes a rather nuanced question. We may as well ignore any sudden death games as they're obviously critical, but which of the remaining games are the most important?

Turns out, perhaps unsurprisingly, that the answer Game 5, but only if the series is tied. This game takes a team from a 50% chance of winning to 75%, cutting their opponents chances in half. This game has the single biggest change in odds one way or another.

But lets face it, teams in the playoffs aren't likely to be even, and there's a well documented home-town advantage in hockey sitting at around 54.5% over the last few seasons. If we assume only a home-town advantage (but otherwise teams are even), how does that effect the playoff model?


Surprisingly, it theoretically doesn't really change the teams' chances at the outset. In fact, the effect is rather diluted by frequently changing who plays where. This is probably good news, as it suggests that seeding order in the playoffs (which depends on teams' previous performance and is somewhat under their control) matters more in playoff series than winning home advantage.

Some differences show up between this model and the previous one, though. If Team A wins the first two games in a row at home, they have a slightly lower chance of winning overall (because they had an advantage then anyway). If team B wins or ties the first two games, they have a slightly higher chance of winning overall, because it's relatively smoother sailing for them from then on. If Team A has tied the series up after game 4, they regain a slight advantage, because they have two home games against one. All in all these differences are rather minor.

But what's far more interesting than theoretical models are actual results. Let's take a look at all playoff series since 1942 (including 14 series of the 2015 playoffs so far):


Here, Team A is both seeded higher than Team B, and has the home advantage. This results in a remarkably different set of probabilities than the first two models shown.

If the question comes back to which game is the most influential, the answer once again is quite different than the previous models. The most critical non-sudden-death game for Team A is actually Game 4 - if Team A is winning then they increase their odds by 18%, but if they're losing at that point they increase their odds by 21% and regain the statistical lead. For Team B, the most influential game is Game 5, for the same reasons as in the 50/50 model previously discussed.

It's important to note that model isn't necessarily applicable to the current Blackhawks v. Lightning Stanley Cup Final. Over half of all playoff series are from the first round of the playoffs, which until recently consisted of teams that were often extremely mismatched (as the top teams would play the 8th-ranked teams, etc.). It's not unreasonable to expect that the two teams who have made it to the Stanley Cup Final are more evenly matched than the average pairing in the first round, so I wouldn't necessarily recommend following along with the chart during this series.

Don't forget to follow along with my NHL Playoff 2015 model and cheer on the Blackhawks (who I had picked to win right the outset of these playoffs!).