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.
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.