0

I'm analyzing some sports data, and I have a set of win/loss records for about 40 teams. I would like to come up with a ranking where each win is weighted by the strength of the opponent. This would have to be some iterative/recursive sort of thing where the weights and ranks are updated on each iteration until convergence. Does anyone know if there is an existing function or package for doing this sort of thing? My guess would is that it wouldn't be a sports-specific package, but I imagine this sort of thing is common across a lot of fields.

EDIT:

Here's some example data. There are 4 teams, A,B,C,and D, and each played the other team once, resulting in 10 unique games. The data are doubled so that each team's four games are listed as their own rows, with the column "a.win" referring to if "team.a" won the game (1=Yes).

dat<-data.frame(
team.a=c("A","A","A","A","B","B","B","B","C","C","C","C","D","D","D","D","E","E","E","E"),
team.b=c("B","C","D","E","A","C","D","E","A","B","D","E","A","B","C","E","A","B","C","D"),
a.win=c(1,1,0,1,0,0,1,0,0,1,1,0,1,0,0,1,0,1,1,0))

From these data, team A won 3/4, B won 1/4, and C,D,and E each won 2/4. But team D beat A, whereas C and E all lost to A. So intuitively D should be ranked slightly higher than C and E since one of its wins came to the highest rated opponent. Similarly, team C lost to team B (the only team with only won win) so intuitively it should be ranked lower than D and E.

I'm trying to figure out how best to assign ranks (e.g., from -1 to 1, or based on probability of winning, or number of losses, etc), and then how best to re-weight each team not just based on the number of wins/losses, but on the rank of the opponent they defeated.

user3037237
  • 385
  • 2
  • 11
  • 2
    As it stands this is a pretty broad question. I would suggest that you add some sort of code and/or data or this will likely be closed. – nrussell Feb 09 '15 at 14:45
  • I'm not sure why this is so broad. I'm just looking for a basic team ranking system that weights by strength of opponent/schedule, but which iteratively calculates the strength based on the previous iteration's ranking. This is common throughout sports, I just can't find a built-in R function that can do this. – user3037237 Feb 09 '15 at 14:56
  • 1
    @user3037237 Please read [**about SO**](http://stackoverflow.com/tour): "Include details about what you have tried"; "Don't ask ... [q]uestions you haven't tried to find an answer for (show your work!)". Also read [**What topics can I ask about here?**](http://stackoverflow.com/help/on-topic): "Questions asking us to recommend or find a [.. ] tool, software library, [...] are off-topic". – Henrik Feb 09 '15 at 15:04
  • I didn't think this applied to asking about specific functions, but good to know in the future. Where, then, is it on-topic to ask about specific R functions? – user3037237 Feb 09 '15 at 15:36
  • @user3037237: I see you deleted your recent question after I encouraged you to make your question concrete by adding data and code. It appears here that you have been given advice similar to what I gave and in the past had used the edit capacity to improve your question. You should also consider posting general methods questions to CrossValidated.com where they will be on-topic if you are only asking for a description of methods and do not insist that answers be delivered in R code or be restricted to R packages. – IRTFM Jul 19 '17 at 16:05
  • The reason why I closed my other post is because I had the feeling you have too much free time and like to lurk around stackoverflow and correct and chastise people, such that my other question was now pointless with you involved in this thread. I think you proved me right. – user3037237 Jul 20 '17 at 17:09

1 Answers1

1

Try the PlayerRatings package.

http://cran.r-project.org/web/packages/PlayerRatings/index.html

It implements the Elo and Glicko ratings used in Chess, but it can be extended to other sports as well. The package also contains functions for updating the ratings of players based on the previous rating and game outcomes. This is a basic starting point, which you will have to build on depending on your situation.

http://en.wikipedia.org/wiki/Elo_rating_system#Elo_ratings_beyond_chess

I don't think there will be a tailored solution for what you want to do, since how you go about ratings will depend on the specifics of your scenario.

dwcoder
  • 478
  • 2
  • 8