Friday, 15 March 2013

Linear Weights to Predict Expected Runs Produced by a Team


In my last post, I talked about Bill James Pythagorean Formula to convert runs for and against into an estimate of winning percentage.

Here are the results for the regular season of an Ontario league.


Team
RF
RA
Actual
Estimated
Diff
A
109
59
0.694
0.773
-0.079
B
94
81
0.605
0.574
0.031
C
92
86
0.556
0.534
0.022
D
74
84
0.447
0.437
0.010
E
106
113
0.421
0.468
-0.047
F
79
102
0.395
0.375
0.020
G
90
119
0.389
0.364
0.025

Notice that the error is less than 10% for all of the estimates.

Pete Palmer provided a method called “Linear Weights” to estimate the number of runs contributed by an individual player.

A simplified version of his formula is

Runs = 0.46*1b + 0.85*2b + 1.02*3b + 1.4*hr + 0.33*walks

The coefficients would need to be modified to apply to this league.   I took all of the individual batting statistics for the league and found that the following formula would be able to estimate the runs produced by each player.

Runs = 0.44*1b + 0.83*2b + 1.00*3b + 1.38*hr + 0.31*walks

Here are the values for Team G.

1B 2B 3B HR Walks Runs
112 11 7 10 29 89

This team actually scored 90 runs.  So this estimate is quite accurate.

Using Linear Weights, I can also estimate the offensive contribution of each player to the team.

In my next post, I show how I can estimate the runs against for a team using pitching statistics.  Then I can use the Pythagorean formula to estimate the winning percentage.





Tuesday, 12 March 2013

Estimating Winning Percentage from Runs For and Against


Bill James created a formula (which he called the Pythagorean formula) to estimate a team’s winning percentage based on their runs for and against.

Winning Percentage = (Runs For)^2 / [ (Runs For)^2 + (Runs Against)^2 ]

During the recent International Softball Federation World Championship, I used this formula to calculate the winning percentage of the teams during the round robin play of the tournament.  Below are the results.

 Pool A

Team
Games
Wins
Runs For
Runs Against
Estimated Win Percentage
Predicted Wins
Difference in Wins
Australia
7
7
48
5
0.989
7
0
Venezuela
7
5
28
17
0.731
5
0
United States
7
4
38
25
0.698
5
-1
Samoa
7
4
31
25
0.606
4
0
Great Britain
7
3
20
18
0.552
4
-1
Czech Republic
7
3
37
38
0.487
3
0
South Africa
7
2
13
37
0.110
1
1
Indonesia
7
0
14
64
0.046
0
0


Pool B

Team
Games
Wins
Runs For
Runs Against
Estimated Win Percentage
Predicted Wins
Difference in Wins
Canada
7
6
44
12
0.931
7
-1
New Zealand
7
6
36
12
0.900
6
0
Japan
7
5
45
13
0.923
6
-1
Argentina
7
5
24
6
0.941
7
-2
Colombia
7
3
17
25
0.316
2
1
Mexico
7
2
19
41
0.177
1
1
Netherlands
7
1
14
57
0.057
0
1
Philippines
7
0
12
45
0.066
0
0


The James Win Percentage Formula did a relatively good job of predicting the winning percentage and thus the number of wins in the round robin portion of the tournament.

The only anomoly seems to be Argentina who allowed very fews runs but scored very few runs.  The Bill James Formula over-estimated their winning percentage.


Saturday, 23 February 2013

How to Determine if a Player is Above Average

So far I have concentrated on Markov Chains and Monte Carlo simulation. Markov Chains use only average teams made up of average players. I used Monte Carlo simulation to evaluate team performance based on the data from particular players.

One of the problems with using data from particular players in fastpitch softball is that the sample size of plate appearances is quite small even when I combine the statistics for 2011 and 2012.

The table below shows the data for 3 players in 2011 and 2012: the plate appearances, the times the player reached base safely, the on-base average, and the lower and upper values of the 95% confidence interval around the on-base average.

Player    PA      OB      Lower    OBA      Upper
1           107      46       0.288     0.430     0.478
2            85       31       0.210     0.365     0.417
3            59       18       0.128     0.305     0.365
 
The league on-base average was 0.373. So players 3 has an upper bound of his 95% confidence interval that is below the league average. So we can say with confidence that this player is significantly below average.

None of the players that have a lower bound that is higher than the league average. So according to this analysis I cannot say that any of players significantly above average.

Another tool that could be helpful in my statistical analysis is Bayes Updating.  This method starts with an estimate of the typical probability of a player being above average and updates the probability as more information is collected.

I will use the statistics for 2011 for the players considered in my earlier post. I will begin with an initial estimate of the probability of being above average of 0.5 and update the estimate based on the 2011 statistics.

Player    PA     OB     OBA     Probability of being above average (2011)
1           49      23     0.469                          0.88
2           46      16     0.348                          0.29
3           38      13     0.342                          0.29
 
So it appears that player 1 is likely to be above average, while players 2 and 3 are likely to be below average.
 
Then I will use the 2011 probability of being above average and update the probability with the 2012 data.
 
Player    2011 Prob    PA    OB    OBA    Probability of being above average (2012)
1               0.88          58    23    0.397                         0.94
2               0.29          39    15    0.385                         0.38
3               0.29          21      5    0.238                         0.05
 
Based on the data from 2011 and 2012 by  applying Bayesian Updating, I safely say that players 1 is above average in terms of on-base average.  Players 2 and 3 who had the same probability of being above average at the end of 2011 look quite different after 2012.  Player 2 is more likely to be above average while player 3 is very likely to be below average.

How Much Does the Batting Order Matter?

In an earlier post, I found the best 9 players out of 14 to have in the lineup. Then in another post, I found the best batting order from this list of 9 players. One could ask, how much does the batting order matter?

I ran 500 trials of 500 seasons of 20 games (i.e. 500*500*20 = 5,000,000 games) for the best batting order and found that the average runs per game was 6.6.

Then I ran 100 random lineups of the best 9 players for 500 trials of 500 seasons of 20 games. I found that the average runs per game for these 100 random lineups was 6.3.

The best of these 100 random lineups had an average runs per game of 6.5 and the worst of these 100 random lineups had an average runs per game of 6.1.

So determining the best batting order has an impact of 0.3 runs per game over just finding the best 9 players and using a random batting order.

Thursday, 21 February 2013

The Impact of Substitutions on Average Runs Per Game

In a previous post, I found the 9 players out of 14 that should be in the lineup. I would now like to answer the question: what is the impact of substituting a player not included in best 9 into the lineup?

Using my Monte Carlo simulation, the best 9 players are expected to score 6.5 runs per game.

The table below shows the average runs per game scored when one of the player not in the lineup (player 4, 5, 8, 9, or 13) is substituted for one of the best 9 players. 

When player 4 is inserted in the lineup for player 1, the average runs per game falls to 5.4.

In the columns of the table, I show the average runs per game when each player is substituted into the lineup for the 9 possible substitutions. One can see that when player 4 is inserted in the lineup, the expected runs per game varies between 6.1 and 5.3 with an average of 5.8.


Substitute Player              4        5       8        9       13       Ave  Lossed Runs
                                                                                                   Per Game
Player Substituted For
         1                            5.4     5.7    5.4     5.0     5.4      5.4        1.1
         2                            5.4     5.6    5.3     5.0     5.4      5.3        1.2
         3                            5.3     5.5    5.2     4.9     5.3      5.2        1.3
         6                            5.9     6.1    5.9     5.5     5.9      5.9        0.6
         7                            6.1     6.4    6.1     5.7     6.1      6.1        0.4
       10                            5.9     6.1    5.9     5.5     5.9      5.9        0.6
       11                            6.1     6.3    6.0     5.7     6.0      6.0        0.5
       12                            6.1     6.3    6.1     5.8     6.1      6.1        0.4
       14                            5.9     6.2    6.0     5.6     6.0      5.9        0.6

Average                          5.8     6.0    5.8     5.4     5.8

Lossed Runs Per Game   0.7    0.5    0.7     1.1     0.7

At the bottom of the table, I estimate the loss in average runs per game when each player is inserted into the lineup.

Player 5 has the least negative impact (a loss of 0.5 runs per game) when inserted into the lineup.

Player 9 has the greatest negative impact (a loss of 1.1 runs per game) when inserted into the lineup.   If he is a defensive specialist, he should be replaced in the batting order by the designated hitter.

The other players 4, 8 and 13 have the same negative impact on runs per game (a loss of 0.7) which is not much different from the substitute with the least negative impact, player 5. 

 Thus, these players (4, 5, 8 and 13) could be substituted into the lineup without much negative impact.

The rows in this table show the impact of taking one of the 9 best players out of the lineup. If player 1 is taken out of the lineup, the average number of runs per game drops to 5.4 from 6.5 (a loss of 1.1 runs per game).

The results in the rows would suggest that players 1, 2 and 3 should not be removed from the lineup unless absolutely necessary. The other players (players 6, 7, 10, 11 and 12) could be replaced with a substitute with relatively less impact on the average runs per game.

Wednesday, 20 February 2013

Finding the Best Batting Order

In my last post, I explained how I used Monte Carlo simulation to find the 9 players that should be in the lineup. In this post, I will show how I found the best batting order using these 9 players..

There are

9*8*7*6*5*4*3*2*1 = 362,880

different batting orders that can be made up from 9 players. So finding the particular batting order that is the best would appear to be difficult but not impossible.

I wrote a program to find these 362,880 batting orders and analyze them using my Monte Carlo simulation.

Here are the 9 players that I suggested should be in the lineup in the last post.

Player    
1        
2        
3        
6        
7        
10     
11      
12    
14    

For all 362,880 batting orders, I ran 10 trials of 100 seasons of 20 games to find all of the sets that had an average of 6.5 runs or more per game. I found 51 potential batting orders to examine in more detail.

Then I conducted a runoff, based on the average number of runs per game, for these 51 batting orders using the program that I discussed in the last post. Again, I ran a simulation with 500 trials of 500 seasons of 20 games.

I found the winner of the runoff was the following batting order.

Player  
2         
1       
3       
10     
11    
12 
7   
6   
14 

On-base average is valued for the leadoff hitter.  Then slugging percentage is valued for the 2, 3 and 4 hitters.  Players with low slugging percentages are relegated to the bottom of the batting order.  .