## Wednesday, June 07, 2017

### Rolling Medians for Time Series Analysis via @BBCNews

 The UK General Election is tomorrow, and while I'm not too bothered who wins or loses, I am interested in the opinion polls and the efforts of the polling companies to get their predictions right. Polling data makes for interesting Time Series Analysis (TSA) - several different methods can be used to analyse the data and make short term forecasts. In my Statistics classes I most often use Moving Averages, Weighted Moving Averages, and Exponential Smoothing as methods for TSA. This year I introduced the more complicated Holt-Winters method. These concentrate on the mean (average) and smoothing factors. The BBC keeps a tracking poll-of-polls and provides an interesting visual to show "voting intention" trends over a period of time. Interestingly, they use the median (the middle value of a set of numbers) instead of the mean (the average value of a set of numbers). The trend lines below are calculated as a "rolling median of the seven latest polls". As the poll-of-polls is updated every day, the median "recalculates to take account of the latest 7 poll values". Here is the BBC visualization: Image source: BBC News.
Taking the poll-of-polls data, I have re-drawn the visual below using a simple seven point moving average (instead of median). The data points (dots) are the same of course, but you'll see slight differences in the trend lines, though they follow the same general trend:

 Data source: BBC News.
In something like a general election, a one percent difference on polling day could have an enormous impact on the number of seats won or lost - especially in the UK's first-past-the-post system. Polling companies are trying many new methods such as considering voter's likelihood of voting, their age (older people are more likely to vote), and their demographics (better off people are more likely to vote). The models are getting more complicated - YouGov's 2017 Election Model makes for very interesting reading - it works by "modelling every constituency and key voter types in Britain based on analysis of key demographics as well as voting behaviour in the 2015 general election and the 2016 EU referendum. Turnout is assessed on voters’ demographics and is based on analysis from 2010 and 2015 British Election Study data". Every day YouGov polls around 7,000 voters - currently their model shows results as follows: Conservatives (311 seats), Labour (255 seats), SNP (51 seats), and Liberal Democrats (10 seats). This is "hung parliament" territory - let's see if they get it right this time!