Formula
The exact formula for determining the RPI of a team at any given time is as follows.
RPI = (WP * .25) + (OWP * .50) + (OOWP * .25)
Where WP is Winning Percentage, OWP is Opponents' Winning Percentage and OOWP is Opponents' Opponents' Winning Percentage.
As mentioned, the WP is weighted based on the locations of the games being played by the team (the other two; OWP and OOWP are not). The exact value of a home win or away loss is .6, whereas the value of an away win or home loss is 1.4. Games played at neutral locations count as 1. When calculating this number, games against subdivision opponents are ignored whether the game is won or lost. As an example, if a team loses to Duke at home, beats them away, and then loses to Cincinnati away, their record would be 1-2. Considering the weighted aspect of the WP, their winning percentage is 1.4 / (1.4 + 1.4 + .6) = .4117
The OWP is calculated in a similar way, ignoring location (every game is worth 1 point) and games against subdivision teams. It does have a few added restrictions, though: first, it ignores the game/games played against the team in question. It also requires that the Opponents being examined have their (unweighted) WP's created before averaging them together. Continuing from above, Duke has played one other game and lost, while Cincinnati has played two other teams and won. Thus the OWP of the team is (0/1 + 2/2)/ number of opponents. OWP = .500
The OOWP is the most elusive number for most people to calculate, but there are a few tricks for finding it. The OOWP is another way of saying your Opponent's OWP; e.g., it would ignore Duke and Cincinnati in the examples above, but would not ignore the team for which you are calculating the RPI. To reiterate, the team in question is part of the team's OOWP (Opponents' Opponents' Winning Percentage). Ignoring this aspect is one of the most common mistakes made in calculating RPI, for, mathematically, it shouldn't be there, and the most re-occurring opponent of your opponents is yourself. Ignoring the team in question causes a large margin of error. Also, you cannot just average the OWP of your direct opponents, as doing so ignores the fact that every team has played a different number of teams; this would unfairly weight the opponents of teams who have played less. Continuing the example above, a team has played Duke twice and Cincinnati once. Duke has played one other game and lost, while Cincinnati has played two other games and won.
Next, for simplicity, assume none of the unnamed teams has played any other games. The OOWP will have these teams this main times in its formula:
(team in question WP) + (team in question WP) + (unknown Duke Opponent WP) + (team in question WP) + (unknown Cincinnati opponent 1 WP) + (unknown Cincinnati Opponent 2 WP) / (number of teams listed).
Plugging in the records and calculating the WP produces the following:
(0/1)+(0/1)+(0/0)+(1/2)+(0/0)+(0/0).
Duke or Cincinnati must be ignored, as they are each other's root opponent. The team in question's record changes for the same reason. Ignoring Duke, this team is 0/1; ignoring Cincinnati, the team is 1/2. The resulting OOWP is .5/6 = .0833
(WP * .25) + (OWP * .50) + (OOWP * .25)
Plugging this in gives you
(.4117 * .25) + (.500 * .50) + (.0833 * .25) = .3737 = RPI