matttrenary / rugby-ratings

Calculate ratings from rugby scores
2 stars 1 forks source link

Ensure math is right #9

Closed matttrenary closed 1 year ago

matttrenary commented 1 year ago

West Chester v Maryland on 10/1/22. A tie, but a big ratings difference. Both teams are +0. Is that right?

grjanke commented 1 year ago

It appears that right now all ties result in +0 ratings, which is wrong.

Here is our error: When there is a tie, margin is 0, so margin_coef = log(abs(margin) + 1) = log(1) = 0. This cancels out the entire ratings update.

I think the Northwestern guy actually made the same mistake!

My Solution

Remove the margin_coef from calculations when there is a tie. This is the same as artificially setting margin_coef to 1. If you do that:

matttrenary commented 1 year ago
  1. Your solution's tie ratings adjustments wouldn't really fit in the curve of the other margins. It can cause weird situations where it's better to tie than win by 1.
  2. I totally forgot to include autocorrelation adjustment coefficient. We need to add this. 2.2/(.001*(the winner's original rating - the loser's original rating)+2.2). It will make a difference in the ratings. It basically reduces the points gained by favorites when they win. And multiples the gains by an underdog when they win.
  3. To solve the original issue of the ln(1)=0 issue with ties. I think we just change x in ln(abs(margin)+x). We can either do it for all margins, or just for a tie. It will have little impact on high margins, and significant impact on low margins. I have an Excel sheet where I was looking at some possibles. I looked at 1.1, 1.5, and 2. I also included the current formula, and the current formula with the auto correlation adjustment. image

It really just depends on what we want. It doesn't seem like the margin formula is set in stone and that 538 just made it up (and didn't account for ties either). Further reading: https://fivethirtyeight.com/methodology/how-our-nfl-predictions-work/ https://stats.stackexchange.com/questions/168047/accounting-for-autocorrelation-in-margin-based-elo-ratings

I guess I'd say the value using 2 looks good for ties, and fits in well with using 1 for the rest of the margins.

matttrenary commented 1 year ago

I implemented using margin+2 for ties. It's operational though arbitrary.

grjanke commented 1 year ago

This is all great. It seems like it's okay to close this issue.

matttrenary commented 1 year ago

I hadn't included the home field coefficient in the auto correlation math. With that added, spot checked results are matching results calculated outside of the system. Reposting results and closing.