# weighting matches by time and variance

I'm putting together a rating system for hockey teams and have data on the number of goals conceded for each team in each game. I would like to come up with a weighting that gives less erratic results than my current model and so I thought a good place to start would be to take in to account the 'time' of the observations and the 'variance' of each observation. For example, consider four teams A,B,C,D, in the first round, we have A vs B and C vs D, and I display their results in the following matrix, named $X_1$:

$$\begin{matrix} ~~~~~~A & B & C &D \\ A~~~~~~~0 & 2 & 0 &0 \\ B~~~~~~~1 & 0 & 0 &0\\ C~~~~~~~0 & 0 & 0 &5\\ D~~~~~~~0 & 0 & 3 &0\\ \end{matrix}$$ where the $(i,j)th$ entry represents the no. of points conceded by team $i$ when facing team $j$. Now, on the second match day, we have games A vs C, B vs D, and $X_2$: $$\begin{matrix} ~~~~~~A & B & C &D \\ A~~~~~~~0 & 2 & 3 &0 \\ B~~~~~~~1 & 0 & 0 &2\\ C~~~~~~~3 & 0 & 0 &5\\ D~~~~~~~0 & 6 & 3 &0\\ \end{matrix}$$ and so on and so forth over each match day I keep updating the matrix with the most recent scores. My rating system takes this matrix as an input at each step, and assigns each team a rating on each match day, and currently gives equal weighting to each observation, but i would like to give a higher weighting to more recent observations, and also a lower weighting to very high observations (for example, if a team has a player sent off and as a result they concede many goals for that game, then i do not consider this to be an accurate depiction of their true quality). I'm not quite sure what the optimal way to do this is, especially for the variance component of the weight, does anyone know of a good way to do this ?

• The use of "optimal" suggests you have a specific intended use for your rating system--but what is it? Predicting wins? Predicting goals? Setting odds for betting? Could you clarify what you mean by "the variance component of the weight"? – whuber Mar 20 '16 at 16:42
• @whuber my main goal is to be able to predict goals conceded by any team, I would like to have this rating as a factor in my model of goals conceded. I'm not quite sure exactly what the variance component would be, initially i was considering looking at the distance from the average score for each team, and discounting values that are 2 standardised deviations or more – WeakLearner Mar 21 '16 at 2:03

If I understand, you want two features.

1) Down-weight or de-emphasize older data as it may be less reflective of the team's current ability level.

2) Down-weight or de-emphasize extreme scores as the information they offer is not linear in terms of score, e.g. allowing 2 scores instead of 1 offers more information than say allowing 8 instead of 7 -- 8 is a little worse than 7 but both are bad.

The solution I offer is a transformation of the scores data that satisfies two features.

Feature 1 may be achieved by including a constant, w1, that is between zero and one and is raised to a power equal to time. I'll be precise in a moment.

Feature 2 may be achieved by taking the log of the scores using a well chosen base, w2. Here is my idea with more precision.

Let i = time on some scale from 1 to infinity, e.g. i is the number of days counting from the first game and the first day of games = 1.

Let Gi = the scores matrix from the ith day of games.

Let Xk = the sum of the day specific score matrices for i <= k.

Consider, Xk = sum over i<=k{ w1^(k-i)*log(w2,Gi+1) } where the log base w2, multiplication by w1^(k-i), and addition of 1 are all being done element-wise on the matrices Gi.

The choice of w1 and w2 will depend on your content knowledge and the performance you observe, but here are some suggestions.

If you base time on date and the hockey season is roughly 210 days long, then w1 = 0.9967 will give a game at the beginning of the season half the weight as a game at the end of the season by the end of the season, i.e. 0.9967^(210-1)=0.5. If time is based on game number and the season is 82 games long, w1 = 0.9915 would have the same effect.

For w2, I thought w2 = 1.5 looked pretty good with that first score counting for a lot and the fourth score counting roughly a third as much as that first score. I also played with a root transformation instead of a log, e.g. raising the scores to the power of 0.85. I personally liked the behavior of the log better.

pts log    change
0   0          .
1   1.71    1.71
2   2.71    1.00
3   3.42    0.71
4   3.97    0.55
5   4.42    0.45
6   4.80    0.38
7   5.13    0.33
8   5.42    0.29

• thanks for the response, I was wondering if you could please make the math a bit clearer (specifically the definition of Xk) perhaps using mathjax, its a bit hard to understand as is – WeakLearner Mar 24 '16 at 3:11