Tuesday, July 24, 2012

On Run Distributions, pt. 7: W% Estimates

There are a number of things one can do with a per game run distribution algorithm. One can look at the scoring patterns of teams to see if they are more or less efficient than a typical team with their average runs scored per game. While this can be done in reference to the empirical distribution for a given set of teams, having a distribution formula that works at multiple points allows one to do some customization, like accounting for park factor, that is problematic when working with the empirical data.

Another application that’s near and dear to my heart is using the run distribution tool to fuel a winning percentage estimator. Most win estimators you see are expressed in terms of a relatively simple function of runs scored and runs allowed, and you never really see how the sausage is made. But the way games are won is to score more runs than the other team. Essentially, any W% estimator is just trying to approximate the proportion of games in which a team will score more runs than it allows. With a function for run distribution, we can write this out explicitly.

Let Ps(k) be the probability of scoring k runs in a game, and Pa(m) the probability of allowing m runs. Then the W% of a team can be estimated as:

W% = Ps(1)*Pa(0) + Ps(2)*[Pa(0) + Pa(1)] + Ps(3)*[Pa(0) + Pa(1) + Pa(2)] + Ps(4)*[Pa(0) + Pa(1) + Pa(2) + Pa(3)] + ...

Of course, there are a number of other ways we could express the same idea, but while the equation above may not be the simplest, I believe it is the clearest. If you score 0 runs, you cannot win. If you score 1 run, you win if you allow 0 runs. If you score 2 runs, you win if you allow either 0 or 1 runs.

There is a complication that arises when employing this logic with a discrete distribution however (if we had a continuous distribution, we would be integrating the difference between the runs scored and runs allowed curves rather than summing, but the idea is the same.) With a continuous distribution, the probability of achieving any given k runs scored or m runs allowed is 0, so one need not be concerned with the run distribution method setting k equal to m. With the discrete distribution, though, we need some way of handling a situation in which a team is estimated to score and allow the same number of runs.

For the sake of this issue, I’ll assume that the Enby distribution is modeling runs in the first nine innings of the game, and that if the game is tied, it will go to extra innings. What is the probability of extra innings?

P(Extra Innings) = Ps(0)*Pa(0) + Ps(1)*Pa(1) + Ps(2)*Pa(2) + Ps(3)*Pa(3) + ...

The probability of extra innings is the probability that you score the same number of runs as you allow. Simple enough. Incidentally, if we assume that the distribution of runs scored and allowed are identical (like we might if we considered the league as an entire unit with some uniform R/G rather than as 30 individual units that only average that R/G when combined), the equation becomes:

P(Extra Innings) = P(0)^2 + P(1)^2 + P(2)^2 + P(3)^2 + P(4)^2 + ...

Knowing the percentage of extra inning games is not enough to estimate W%--we also need to know the percentage of those contests that the team goes on to win. For this, we will fall back once again on the Tango Distribution, which allows us to consider scoring on the inning level.

Before I actually use the Tango Distribution, allow me to walk through this with a simple example. The important factor in determining the probability of winning in extra innings is the percentage of the time that a team scores more runs in an inning than they allow. As soon as you do that, you win. As soon as you allow more than you score in an inning, you lose. As long as you score as many runs as you allow in an inning, the game continues.

Let’s suppose that a team has a 25% chance of scoring outscoring their opponent in a given inning and a 20% chance of being outscored. This means that there is a 55% chance of a tie in each inning, which extends the game. Thus, the probability of winning eventually is:

.25 + .55*.25 + .55^2*.25 + .55^3*.25 + .55^4*.25 + ...

You have a 25% chance of winning in the tenth inning and a 55% chance of their being an eleventh inning. In each subsequent inning, there is also a 25% chance of winning and a 55% chance of the game continuing. This expression can be solved as follows:

.25[1 + .55 + .55^2 + .55^3 + .55^4 + ...] = .25*1/(1 - .55) = .5556

However, you don’t even need to deal with the 55% probability of an additional inning, thanks to the Craps Principle. As you can see, the expression .25*1/(1 - .55) simplifies to .25/.45 which is equal to the probability of winning the first round divided by the sum of the probability of winning the first round and the probability of losing the first round, so we can just take .25/(.25 + .2) = .5556.

Bringing the Tango Distribution back into play, let Fs(k) be the probability of scoring k runs in an inning and Fa(m) the probability of allowing m runs in an inning. By “win inning”, I mean outscoring the opponent in a single inning; by “lose inning”, I mean being outscored in a single inning.

P(win inning) = Fs(1)*Fa(0) + Fs(2)*[Fa(0) + Fa(1)] + Fs(3)*[Fa(0) + Fa(1) + Fa(2)] + Fs(4)*[Fa(0) + Fa(1) + Fa(2) + Fa(3)] + ...

P(lose inning) = Fa(1)*Fs(0) + Fa(2)*[Fs(0) + Fs(1)] + Fa(3)*[Fs(0) + Fs(1) + Fs(2)] + Fa(4)*[Fs(0) + Fs(1) + Fs(2) + Fs(3)] + ...

P(win in extra innings) = P(win inning)/[P(win inning) + P(lose inning)]

P(extra innings) = Ps(0)*Pa(0) + Ps(1)*Pa(1) + Ps(2)*Pa(2) + Ps(3)*Pa(3) + ...

P(win in 9 innings) = Ps(1)*Pa(0) + Ps(2)*[Pa(0) + Pa(1)] + Ps(3)*[Pa(0) + Pa(1) + Pa(2)] + Ps(4)*[Pa(0) + Pa(1) + Pa(2) + Pa(3)] + ...

W% = P(win in 9 innings) + P(extra innings)*P(win in extra innings)

Let me demonstrate how this estimate is figured with a table. Let’s take a team that averages 5 runs scored and 4 runs allowed per game. We first use Enby to estimate the probability of scoring or allowing k runs (I’ve capped scoring at 25 runs here; technically, you need to go to infinity):



The columns “score” and “allow” are the probabilities of scoring k runs. “allow <” is the probability of allowing less than k runs. “win 9” is the probability of winning the game in nine innings while scoring k runs, and is equal to the probability of scoring k runs times the probability of allowing less than k runs. “extra” is the probability of extra innings with a score of k-k, and is the product of the probability of scoring k runs and the probability of allowing k runs. The sum of “win 9” is the probability of winning in 9 innings, which works out to .5409 in this case. The sum of “extra” is the probability of extra innings, which is 9.95%. To complete our analysis, we need to do a similar analysis on the inning level using the Tango Distribution:

Here, I’ve added a “score <” column, which is the probability of scoring less than k runs. “lose” is the probability of losing given k runs scored and is the probability of allowing k runs times the probability of scoring less than k runs. “tie” here is the same as “extra” in the above chart, although it is also 1 - win - lose. The sum of “win” is the probability of winning the inning; the sum of “loss” is the probability of losing the winning. The probability of winning the inning divided by the sum of the probability of winning and losing the inning is the probability of winning an extra inning game (per the craps principles). In this case, the probability of winning an inning is 24.8%, the probability of losing an inning is 20%, and the probability of tying an inning is 55.2%.

Thus, the probability of winning given extra innings is .248/(.248 + .20) = .5534, and the overall probability of winning is:

.5409 + .0995*.5534 = .5960

Remember, .5409 is the probability of winning in 9 innings; the probability of winning given that the game only goes nine innings is .5409/(1 - .0995) = .6007. Obviously the team with the advantage has a greater probability of winning a nine inning game than winning a one inning game.

For comparison, Pythagenpat with z = .28 estimates that a 5 R/4 RA team will have a .6018 W%, a difference of .94 games over a 162 game season from the Enby estimate. The Tango-Ben distribution (using the same methodology as what I just demonstrated except substituting the Tango-Ben estimate of the game scoring probabilities for Enby) estimates .5953 when using c = .767, which is a good match for the Enby estimate. However, Tango found that for applications involving two teams in a head-to-head matchup, a c parameter of .852 produces better results. Using .852, the Tango-Ben distribution estimates a .6011 W%, a much better match for Pythagenpat.

It is quite possible that Enby would benefit from a separate set of parameters for use in a head-to-head matchup. This could be accomplished by modifying the variance targeted by the Enby parameters, and when I pick this topic back up in a few months I have some ideas on how to do that.

Given the complexity of the W% estimate and its questionable accuracy (at least with the current default parameterization) I have not endeavored to carry out more elaborate tests. For now, it will sit as an intellectual exercise rather than as a method I use.

No comments:

Post a Comment

I reserve the right to reject any comment for any reason.