
A Markov chain is a type of mathematical model thatis well suited to analyzing baseball, that is, to what Bill Jamescalls sabermetrics. The concept of a Markov chain is not new,dating back to 1907, nor is the idea of applying it to baseball,which appeared in mathematical literature as early as 1960. Infact, it is not unusual to see sabermetric analysis that incorporatesthe fundamental ideas of a Markov chain without formally usingthe mathematical structure. This type of work typically employssituational analysis and studies the probabilities and effectson expected scoring of moving from one base runners and outs combinationto another. An example is the calculation of break-even probabilitiesfor attempting to steal a base. However, formal Markov chain analysisof baseball is not at all common and is rarely found outside ofacademic studies. The main reasons for this are 1) most sabermetricianshave never heard of Markov chains, 2) obtaining sufficient datahas been rather difficult, and 3) a computer is a virtual necessityfor serious Markov chain analysis. Project Scoresheet has takencare of the second problem, and the advent of personal computersand advanced software brings the solution to the third problemwithin the means of many sabermetricians. This essay attemptsto do something about the first problem, but none of the mathematicaldetails are presented since that would be inappropriate here.
There are three main sections that follow. The firstis a nontechnical description of Markov chains and applying themto baseball. The second section discusses the types of sabermetricanalyses that can be performed using Markov chains. The thirdsection describes some of the author's work with Project Scoresheetdata to develop prototype Markov analytical capabilities, andpresents examples, which are for illustrative purposes only becauseof the limited scope of the data, that demonstrate the workingsof some of the Markov concepts.
From a mathematical point of view, a Markov chaindescribes a process that can be considered to be in exactly oneof a number of "states" at any given time. A baseballhalf-inning (the half- will be left out for brevity in the restof this paper) fits that description if the states are consideredthe various runners and outs situations. There are 24 such combinations,which are listed below using the notation (runners,outs):
TABLE 1: RUNNERS AND OUTS COMBINATIONSRunners: 0(none)1 2 3 12 13 23 123 0: (0,0) (1,0) (2,0) (3,0) (12,0) (13,0) (23,0) (123,0) Outs 1: (0,1) (1,1) (2,1) (3,1) (12,1) (13,1) (23,1) (123,1) 2: (0,2) (1,2) (2,2) (3,2) (12,2) (13,2) (23,2) (123,2)There also is a three out state, and to be technically correctthere should be four three out states, corresponding to whether0, 1, 2, or 3 runs scored on the play.
The heart of the Markov chain is the analysis ofthe transitions between the states. The key is the so-calledtransitionmatrix that contains the probabilities of moving from anystate to any other state. Many of the transitions in baseballare impossible (e.g. the number of outs can never decrease) andhave probability equal to zero. The other transitions have probabilitiesdetermined by the chances of various baseball events.
For sabermetric purposes, it is useful to have morethan one transition matrix. One necessary refinement is to distinguishbetween transitions ("plays") that change the batterand those that do not. For example, suppose an inning is in thestate (1,0) [runner on first, none out] and after the play itis in the state (2,0) [runner on second, none out]. If the batterchanged, then the runner scored, most likely on a double. However,if the batter did not change, then the runner on first advancedto second (SB, WP, PB, balk) and no run scored. One way of handlingthis is to define additional states that indicate whether or notthe batter changed, but that proves to be mathematically cumbersome.A better method is to have one transition matrix for plays thatchange the batter and a second one for plays that do not. In fact,there is no reason to stop at two. When performing strategy analysis,it makes sense to distinguish transitions for which the strategyis in effect from the others. Along these lines, it seems reasonableto establish separate transition matrices for such things as pitchersbatting, sacrifice bunts and attempts, stolen bases and caughtstealings, intentional walks, and so forth.
Closely associated with a baseball Markov chain,though strictly speaking not part of it, is theruns aftermatrix. For each of the 24 runners and outs states listedin Table 1, this matrix records what percentage of the time aspecific number of runs scoredin the remainder of the inning.For example, after the (0,2) state, there may have been 0 runs82% of the time, 1 run 14%, 2 runs 2%, etc. From this matrix,it is easy to compute the expected or average number of runs forthe rest of the inning. These expected run values for each stateare commonly used in situational and strategy analysis to computebreak-even probabilities. Note that the expected number of runsafter the (0,0) state, in which all innings begin, is the averagenumber of runs per inning.
There is a rich mathematical theory of Markov chains,but most of it is not applicable to baseball. (The three out stateis an "absorbing" state because once entered, it can'tbe left. Most of the theory concerns chains without absorbingstates.) Perhaps the greatest benefits from considering an inningas a Markov chain come from being able to formulate a large numberof complex calculations in terms of matrix notation. The use ofmatrix algebra, as opposed to keeping track of numerous casesand equations, can greatly simplify the entire analytical process.A spreadsheet program on a personal computer is a natural settingfor sabermetric work in general, and these programs with theirrow and column organization lend themselves naturally to matrixmanipulations. The latest versions have matrix multiplicationand matrix inversion commands, which are a virtual necessity forMarkov chain analysis. The Markov chain and matrix algebra formulationenables the consideration of a wider range of questions and evenmakes getting the answers easier.
One fascinating computation that can be performedis to compute from a transition matrix the average or expectednumber of runs after each of the 24 runners and outs combinations.In particular, the expected runs after the (0,0) state is theaverage scoring per inning, and in a sense 9 times this numberis average scoring per game. The key to this analysis is to startfrom an "interesting" transition matrix.
If the transition matrix contains only plays in whichno strategy was involved (i.e. "hitting away"), thenthe values obtained are baselines against which strategies canbe analyzed. One way of analyzing the strategy is to modify thetransition matrix to include the strategy and then compute theexpected runs again. For example, if the goal is to determinethe effect on scoring of the actual stolen base attempts in agroup of games, say for a whole league in a season, then the expectedruns computation could be carried starting from a transition matrixwithout any steal attempts and again starting from the same transitionmatrix augmented by the steal attempts. Because the expected runsfollowing all situations are calculated, it would be possibleto see if the actual strategies increased scoring in some cases,say after (1,2), but not after others, say (1,0), in additionto telling if overall scoring increased or decreased.
Another application of this idea is to evaluate theoffensive performance of individual players. Suppose we have atransition matrix for one player by himself. That matrix couldbe obtained from collecting data on all his plate appearances(and base running events if desired), or it could be estimatedfrom season or career statistics. Calculating the expected runsper inning from that matrix yields an estimate of how much scoringthere would be if that player batted (and ran) all the time. Multiplyingthe runs per inning by nine produces an offensive run averagefor the player. The player's average could be compared to a leagueaverage computed from a transition matrix based on all players.
Markov chain techniques can be used to compare differentbatting orders. The basic idea is again to compute the expectedruns per inning associated with each batting order being analyzed.In this case, the computations are more complicated because ninedifferent transition matrices are involved and how often eachplayer leads off an inning must be accounted for. However, thenecessary calculations are feasible, and there are often simplifyingassumptions that can be applied to answer specific questions.
A different use of the transition matrix is to studypossible differences between ballparks, teams, playing surfaces,etc. The idea is to examine specific transitions that can shedlight on the issue. For example, suppose the goal is to determinewhether it is harder to score from second base on a single inan astroturf or grass park. Of course, the best way is to go throughthe play-by-plays from a large of number of suitable games andcollect the specific data. However, this may prove to be difficult,and the transition data if available can be of use. In this case,the idea is to examine transitions from a state with a runneron second to a state that was almost certainly reached by a single.This requires first base to be open so short singles can be distinguishedfrom walks, which reduces to a runner on second or runners onsecond and third. The appropriate transitions are listed below:
TABLE 2: SCORING FROM SECOND ON A SINGLE (I) End state after "single" Start State Runner on 2nd scored did not score (2,0), (23,0) (1,0), (0,1) (13,0), (1,1) (2,1), (23,1) (1,1), (0,2) (13,1), (1,2) (2,2), (23,2) (1,2) (13,2)In addition, there maybe a small number of transitions to three out states that resultfrom singles, but there is no way to distinguish these from othertransitions to the three out states. The number of such playsis probably too small to be meaningful in this analysis. A largerproblem is that the transitions do not distinguish singles fromother plays where the batter reaches first such as errors or fielder'schoices. However, since the object is to compare two parks orplaying surfaces, it is likely that the proportion of non-singlesis similar for both, and the comparison will be valid.
By this point, you may be wondering if anyone wouldreally go to the trouble of doing all of this. The answer is definitelyyes. Most, but not all, of this type of work has been done byacademic researchers. In some cases, simplifying assumptions weremade or a reduced problem was studied. However, more complex analysesalso have been performed. The description of the use of ProjectScoresheet data that follows shows that elaborate computer facilitiesare no longer required for Markov chain baseball analysis.
The author has been a Project Scoresheet inputterfor the past two years. The inputters enter plays from the scoresheetsinto IBM PC and compatible personal computers using programs suppliedby the project director. These programs write data files on floppydiskettes that contain all the information needed to reconstructthe games. The author input 37 Baltimore home games in 1985 and74 Cincinnati home games in 1986 and kept copies of the data files.All the examples below are drawn from these games and as suchform a limited and probably non-representative sample. Thus, anydata or conclusions should not be considered to be representativeof either league or of major league baseball.
The first step is the extraction from the data filesof the information needed for the transition and runs after matrices:counts of how often each transition took place and how often specificnumbers of runs scored after each situation. The author has writtena program using the BASIC language for this task. The programkeeps track of six different types of transitions: 1) non-pitchershitting away, 2) pitchers hitting away, 3) intentional walks,4) sacrifice bunts and attempts, 5) stolen bases and caught stealings,and 6) other transitions that do not change the batter (WP, PB,balk, etc.). In addition, these transitions and the runs afterare separated into those for the home team, Baltimore or Cincinnati,and those for the visiting teams. The program defines a sacrificebunt attempt to be any bunt with none out and men on base or anybunt by a pitcher with one out and men on base. Any credited sacrificehit is counted as a such. Because the data files are structuredin a way that makes the determination of the score at any pointin the game difficult, the definition of sacrifice is not dependenton the game score.
The BASIC program writes disk files that can be readinto the Lotus 1-2-3 spreadsheet program, which is used for theremainder of the analysis. Spreadsheets are an ideal way to manipulatetransition data and perform the needed calculations. Moreover,release 2 of 1-2-3 has commands to multiply and invert matrices,which are almost a necessity for Markov chains and similar typesof computations.
Table 3 below shows for each of the 24 runners andouts combinations 1) how many times each occurred in the observed(from the scoresheets) data, 2) the observed probability of scoringat least one run after the combination (useful for strategy analysis),3) the observed average runs after, and 4) the average runs aftercomputed from the Markov chain. For the NL (Cincinnati home games)data, two averages are shown, one which excludes the pitchersand one including the pitchers. These averages are calculatedonly from the hitting away transitions, while the observed averagesreflect the effects of all plays. The probability of scoring atleast one run is more difficult to calculate from the Markov chainformulation, and it has not been carried out at this time.
TABLE 3: OBSERVED AND THEORETICAL SITUATION DATA37 BALTIMORE HOME GAMES IN 1985 (ALL TEAMS) OBSERVED MARKOV Prob. Avg. Avg.Situation Number of runs runs runs 1 (0,0) 691 0.288 0.530 0.536 2 (0,1) 505 0.180 0.323 0.292 3 (0,2) 393 0.079 0.125 0.117 4 (1,0) 171 0.415 0.854 0.910 5 (1,1) 216 0.282 0.583 0.559 6 (1,2) 219 0.100 0.210 0.220 7 (2,0) 46 0.696 1.435 1.253 8 (2,1) 74 0.473 0.689 0.760 9 (2,2) 89 0.270 0.382 0.36610 (3,0) 4 1.000 2.250 1.55711 (3,1) 24 0.667 1.333 1.08812 (3,2) 37 0.297 0.351 0.37413 (12,0) 42 0.667 1.524 1.38014 (12,1) 74 0.446 1.014 0.92315 (12,2) 101 0.277 0.554 0.50716 (13,0) 16 0.875 1.875 1.73617 (13,1) 42 0.786 1.524 1.40918 (13,2) 48 0.292 0.542 0.50919 (23,0) 8 0.500 0.875 1.82020 (23,1) 32 0.531 1.156 1.30921 (23,2) 28 0.143 0.357 0.25122 (123,0) 16 0.875 1.938 2.11823 (123,1) 30 0.567 1.133 1.44724 (123,2) 40 0.250 0.600 0.480 ---- 2946It should be noted that the Markov calculations forexpected (average) runs after each situation assume all battershave the average transition probabilities. In actuality, eachbatter has a different transition matrix, which could be accountedfor in the Markov calculation, but such a degree of complicationis beyond the scope of the current effort. Also, the Markov calculationsshown above exclude the effects of intentional walks, sacrificebunts and attempts, stolen bases and attempts, and other playsthat do not change the batter. This can be an advantage when analyzingstrategies for the effect on expected runs because these calculationsexclude the effects of some primary strategies. For these reasonsand others, the observed average runs do not match the Markovcalculations. The two are fairly close in many cases for the ALdata, but the theoretical calculated values tend to be higherthan the observed values for the NL data.74 CINCINNATI HOME GAMES IN 1986 (ALL TEAMS) OBSERVED MARKOV Prob. Avg. Avg. runsSituation Number of runs runs no pit. w/pit. 1 (0,0) 1397 0.295 0.515 0.570 0.527 2 (0,1) 1000 0.162 0.259 0.297 0.270 3 (0,2) 804 0.071 0.102 0.114 0.103 4 (1,0) 369 0.472 0.900 1.017 0.955 5 (1,1) 395 0.281 0.532 0.622 0.578 6 (1,2) 408 0.145 0.243 0.281 0.254 7 (2,0) 110 0.609 0.955 1.098 1.034 8 (2,1) 202 0.411 0.678 0.632 0.599 9 (2,2) 246 0.236 0.325 0.360 0.33010 (3,0) 26 0.923 1.423 1.533 1.49811 (3,1) 69 0.667 0.942 1.015 0.94512 (3,2) 125 0.272 0.408 0.373 0.35513 (12,0) 83 0.735 1.590 1.797 1.70314 (12,1) 127 0.480 1.087 1.148 1.07915 (12,2) 194 0.242 0.407 0.514 0.46916 (13,0) 34 0.824 1.353 1.815 1.74817 (13,1) 66 0.667 1.045 1.255 1.16118 (13,2) 77 0.234 0.351 0.451 0.39119 (23,0) 11 0.818 1.909 1.778 1.71520 (23,1) 55 0.745 1.455 1.413 1.35021 (23,2) 57 0.404 0.772 0.726 0.71522 (123,0) 22 0.955 2.091 2.402 2.28223 (123,1) 55 0.764 1.764 1.966 1.78624 (123,2) 73 0.288 0.521 0.751 0.654 ---- 6005
Table 4 summarizes the scoring from second on a singleexercise described previously. In both cases, only non-pitcherhitting away transitions are counted.
TABLE 4: SCORING FROM SECOND ON A SINGLE (II) 1985 BALTIMORE GAMESStart Situation: (2,0)&(23,0) (2,1)&(23,1) (2,2)&(23,2)End Situations: number --runner on second scores (1,0): 4 (1,1): 4 (1,2): 10 (0,1): 1 (0,2): 1 --runner on second does not score (13,0): 4 (13,1): 12 (13,2): 2 (1,1): 0 (1,2): 0Scoring percentage: 5/9 = .556 5/17 = .294 10/12 = .833Because the Orioles and Reds players are involvedoffensively or defensively in all plays, these transitions can'tbe considered to be a direct comparison between grass and astroturf.That being said, the above evidence does not support a conclusionthat it is easier or harder to score from second on a single ineither of the two parks. The only thing shown is the unsurprisingobservation that runners score from second far more frequentlywhen there are two outs.1986 CINCINNATI GAMESStart Situation: (2,0)&(23,0) (2,1)&(23,1) (2,2)&(23,2)End Situations: number --runner on second scores (1,0): 6 (1,1): 12 (1,2): 26 (0,1): 1 (0,2): 0 --runner on second does not score (13,0): 6 (13,1): 12 (13,2): 6 (1,1): 2 (1,2): 4Scoring percentage: 7/15 = .467 12/28 = .429 26/32 = .813
Next, the thorny issue of the sacrifice bunt is considered.Because of data limitations the investigation is confined to situationswith a runner on first only. For the AL, the no outs situationis the only one for a potential sac try, but in the NL, pitcherswill often bunt with one out. These bunts should be evaluatedagainst the objective of increasing the chances of scoring atleast one run. In general, the sac bunt reduces overall scoringbecause it creates an out. One important point is that the probabilitiesof scoring (at least one run) used are drawn from the observeddata, and hence they include the effects of all plays and strategies,including bunts and stolen base tries. That means these probabilitiesare not the best for the typical type of break-even analysis.Instead, the tables below compare the probabilities of scoringbefore the bunt, those shown in Table 3 for (1,0) and (1,1), withthe probabilities resulting from the outcomes of the actual sacrificebunt attempts.
TABLE 5: SACRIFICE BUNT ATTEMPT ANALYSIS BALTIMORE GAMES (bunts with runner on first, no outs)Ending situation Number Percent Scoring Probability(0,2) [Double play] 1 .056 .079(2,1) [Sac worked] 14 .778 .473(12,0)[Batter safe] 3 .167 .667 -- 18 Average probability of scoring after bunt = (.056)(.079) + (.778)(.473) + (.167)(.667) = .483Probability of scoring after (1,0) = .415Net GAIN from sacrifice bunt attempt = .068The number of bunt transitions is not nearly largeenough to support any definitive conclusions, but it is stillinteresting to interpret the above data. The sacrifice bunt aspracticed in the games sampled appears to have been a good play.There is a meaningful increase in the probability of scoring atleast one run in the AL games, a small increase for the NL oneout bunts, and a sizeable decrease for the NL no out bunts. However,all of the NL one out bunts and many if not most of the NL noout bunts are by pitchers. With a pitcher hitting away, the actualprobability of scoring after (1,0) or (1,1) is much less thanthe values shown, which are based on all players. Thus, the NLcomparisons are more in favor of the bunt, especially with pitchersbatting, than shown, although the exact amount can't be quantifiedfrom the data available.CINCINNATI GAMES (bunts with runner on first, no outs)Ending situation Number Percent Scoring Probability(0,2)[Double play] 3 .077 .071(1,1) [Sac failed] 4 .103 .281(2,1) [Sac worked] 28 .718 .411(12,0)[Batter safe] 4 .103 .735 -- 39Average probability of scoring after bunt = (.077)(.071)+ (.103)(.281) + (.718)(.411) + (.103)(.735) = .404Probability of scoring after (1,0) = .472Net LOSS from sacrifice bunt attempt = .068
CINCINNATI GAMES (bunts with runner on first, one out)Ending situation Number Percent Scoring Probability3 out [Double play] 1 .063 .000(1,2) [Sac failed] 3 .188 .145(2,2) [Sac worked] 9 .563 .236(3,1) [Runner scored, batter reached 3rd on error] 1 .063 1.000 (run scored on bunt)(12,1) [Batter safe] 1 .063 .480(23,1) [Batter safe, both advance extra base on error] 1 .063 .745 -- 16Average probability of scoring after bunt = (.063)(0)+ (.188)(.145) + (.563)(.236) + (.063)(1) + (.063)(.480) + (.063)(.745) = .299Probability of scoring after (1,1) = .281Net GAIN from sacrifice bunt attempt = .018
Some caveats are in order. First, the calculationsare based on average values. Specific batters will differ fromthe average to some extent, so any conclusions must be appliedwith care. A second consideration is that some bunt transitionsmay not have been tabulated because the scoresheet may have failedto indicate a bunt. This does not effect credited sacrifices,but could effect both failed sacs and sac tries that result insingles. A similar, and perhaps more serious problem, is thatthe scoresheets do not indicate when a batter tried unsuccessfullyto bunt until he had two strikes and then hit away, presumablyat a disadvantage. Bunted third strikes are generally recordedand counted as sac try transitions, but there may some cases wherethe bunt indication is missing on the scoresheet.
Most sabermetric analysis has denigrated the sacrificebunt. Although not discussed here, it is almost certain that thesac bunt try decreases total scoring. Much of the published analysissupports the case that the bunt is not a good play to try to scoreone run. The above supports the opposite, even for non-pitchers,keeping in mind that the data used are obviously limited.
It is tempting to try to use Table 5 to compare buntingon grass and astroturf. It is true that the percentage of failedsac tries is higher for the Cincinnati data, but there is a possibleexplanation other than the playing surfaces. The NL bunts aremainly the efforts of pitchers, and the AL bunts, of course, areall by non-pitchers. In general, pitchers bunt in sacrifice situationswhether or not they are good bunters. However, a non-pitcher whois a poor bunter is rarely asked to bunt. Thus, there is a goodchance that the lower success rate in Cincinnati is due to pitchers.What is needed is to isolate the non-pitcher bunts in the NL data,but that was not done for this study.
The final analysis presented concerns the stolenbase. Attempted steals are judged against two objectives, increasingthe chances of scoring at least one run and increasing the expectednumber of runs. Because of the relatively small number of transitions,the calculations shown are confined to situations with a runneron first and no other runners. The expected runs shown in Table6 are the theoretical values computed from the Markov chain fornon-pitcher hitting away transitions, which are used because theyare generally free of the effects of strategies and certainlyare not influenced by stolen bases.
TABLE 6: STOLEN BASE ATTEMPT ANALYSIS BALTIMORE GAMES (runner on first, no outs) Ending Scoring Expected Situation Number Percent Probability Runs (0,1) [CS] 3 .214 .180 0.292 (2,0) [SB] 10 .714 .696 1.253 (3,0) [SB&E;] 1 .071 1.000 1.557 -- ----- ----- 14 Weighed Avg: .607 1.069 Values for (1,0): .415 0.910 Gain/loss from SB try: .192 0.159[The weighted averages are computed using the method shown in Table 5.]The scoring probability of 1.000, which means certainty,shown for the (3,0) Baltimore data is based on just four observations.The true probability is a little lower, but that is unlikely toaffect the results of this study. One caveat: it is quite possiblesome plays that should have been scored as caught stealings wereinstead scored as pick-offs. The tabulation program counts pick-offsas other transitions that do not change the batter, not at stolenbase attempts. Thus, the data in Table 6 may have a small biasin favor of the stolen base. With that in mind, readers are invitedto draw their own conclusions from Table 6.BALTIMORE GAMES (runner on first, one out) Ending Scoring Expected Situation Number Percent Probability Runs (0,2) [CS] 5 .333 .079 0.117 (2,1) [SB] 10 .667 .473 0.760 -- ----- ----- 15 Weighed Avg: .342 0.545 Values for (1,1): .282 0.558 Gain/loss from SB try: .060 -0.013
BALTIMORE GAMES (runner on first, two out) Ending Scoring Expected Situation Number Percent Probability Runs 3 out [CS] 7 .438 .000 0.000 (2,2) [SB] 9 .562 .270 0.366 -- ----- ----- 16 Weighed Avg: .152 0.205 Values for (1,2): .100 0.219 Gain/loss from SB try: .052 -0.014
CINCINNATI GAMES (runner on first, no outs) Ending Scoring Expected Situation Number Percent Probability Runs (0,1) [CS] 11 .324 .162 0.297 (2,0) [SB] 19 .559 .609 1.098 (3,0) [SB&E;] 4 .118 .923 1.533 -- ----- ----- 34 Weighed Avg: .501 0.890 Values for (1,0): .471 1.017 Gain/loss from SB try: .030 -0.127
CINCINNATI GAMES (runner on first, one out) Ending Scoring Expected Situation Number Percent Probability Runs (0,2) [CS] 18 .409 .071 0.114 (2,1) [SB] 26 .591 .411 0.632 -- ----- ----- 44 Weighed Avg: .272 0.419 Values for (1,1): .281 0.621 Gain/loss from SB try: -.009 -0.202
CINCINNATI GAMES (runner on first, two out) Ending Scoring Expected Situation Number Percent Probability Runs 3 out [CS] 20 .282 .000 0.000 (2,2) [SB] 42 .648 .236 0.360 (3,Q) [SB&E;] 5 .070 .272 0.373 -- ----- ----- 71 Weighed Avg: .172 0.259 Values for (1,2): .144 0.280 Gain/loss from SB try: .028 -0.021
While the calculations presented in the above tablesmay seem tedious and laborious, they were performed rather quicklyfrom a few matrix multiplications that also produced additionalinformation not shown above. Once the transition matrices havebeen set up in the spreadsheet environment, it is easier to dothe computations than to write about them! This is a dramaticillustration of the analytical power that results from the combinationof Markov chain techniques and Project Scoresheet data.