# Introducing the Batter-Specific Run-Expectancy Tool

Today at FanGraphs, we’re introducing an interactive run-expectancy tool that incorporates the batter’s skill into the run-expectancy value. The tool, developed by the rather incredible Sean Dolinar, allows the user to input a few factors, including one to account for the batter, and in turn spits out a number estimating how many runs will be scored for the rest of the inning.

###### For an explanation on how to use the tool, scroll to the bottom of the post.

Run expectancy, or RE, is a crucial part of all baseball analytics. It’s our basis for linear weights and wOBA, it’s closely related to win probability, and it’s the foundation for one of our most important storytelling stats, RE24. But it often fails to capture the whole situation. The batter at the plate, obviously, has an effect on what will happen next. If you have the bases loaded with one out, the run expectancy is going to be very different with Mike Trout up than with Mike Zunino. With Trout up, you’re happy with your chances to score. With Zunino… not so much.

The run expectancy for a given situation is calculated by taking the average number of runs scored for the rest of the inning in similar situations. “Similar situations” means other plate appearances that start with the same base-out state (i.e., runner on second with one out) and the same run environment (which is important, because the AL in 2001 was very different from the NL in 2014). But in order to encapsulate the change that comes with different types of batters, more factors are necessary.

An easy additional factor to account for batter skill is the wOBA of the batter at the plate. The question is, though, what number to use for the batter’s wOBA? One could use all sorts of different samples: their career wOBA, their overall wOBA that season, or their wOBA that season to date.

The one on which I settled using is the batter’s regressed wOBA from current season using the methodology that Sean and I wrote about last June. Each regressed wOBA was rounded to the nearest .010 (.327 would become .330, for example) to make the groupings less granular, with a bigger sample size in each grouping. (My data set was all plate appearances since 2009, since that’s the year to which our regression research dates back.)

Additionally, for this project, the run environment was calculated by taking the average team runs per game in that league in that *month*. Scoring varies a bit by month, so I chose to use months instead of years. I rounded each month’s scoring to the nearest 0.25. This yielded six categories: 3.75 runs per game per team up to 5, incrementing by 0.25. There have been 84 league-months since 2009 (March/April and September/October were both treated as one month). Run environments of 4.00, 4.25, and 4.50 have all occurred at least 20 times; the others are rarer, but they all have happened more than once.

But back to wOBA. As one might expect, batter wOBA turns out to have a tremendous effect on RE. As an example, look at the following situation: Bases loaded, one out, with a run environment of 4.5 runs per game.

However, while the overall correlation is very strong, there are some slight outliers. Run expectancy goes down in some situations when wOBA increases; look, for example, at the decrease from a wOBA of .360 to .370. The numbers need to be smoothed out.

So instead of just taking the original RE value of every grouping, I instead ran a simple linear regression within each grouping of base-out state and run environment. The independent variable was wOBA and the dependent variable was RE. For each combination of base-out state and run environment, there is a unique regression equation modeling run expectancy based on batter wOBA.

This comes with some problems, though. With 144 possible groupings (24 base-out states and six different run environments), some groupings just haven’t occurred all that often over the past seven years, and there’s great uncertainty with the regression equation. One such grouping is no outs and runners on the corners in a run environment of 5.0 runs per game, which has occurred only 136 times since 2009.

The slope is *negative*. This is certainly wrong. Run expectancy should not decrease when the batter at the plate is better. And this is only one of eight situations where the slope of the regression line is negative. Additionally, 43 out of the 144 regressions had a p-value over 0.1, meaning that there was at least a 10% chance that wOBA had no effect at all, which we can assume not to be true. For some situations (like the one shown in the first graph), this method works perfectly. But there are far too many where it fails.

To solve that problem and get larger sample sizes in the groupings, I stopped grouping by run environment and grouped solely by base-out state. Instead of run environment serving as its own category, it became a variable in the regression. There are now 24 different regression equations rather than 144.

There are several advantages that come with putting run environment inside the regression equation. For one, the regressions are much more meaningful: all the equations have a p-value under 0.05 (and all but one have a p-value under .001). It also makes the whole system much simpler by having six times fewer equations to deal with. And all of the coefficients for both wOBA and run environment are positive, which is somewhat of a validation of the equations; or, at least, they’re not invalidated by any negative coefficients. Furthermore, better fits aren’t achieved by factoring in any interactions between wOBA and run environment, nor by transforming either of those variables (squaring, logging, etc.).

Interestingly, the situations with the lowest run expectancies (across all run environments) had the best fits. The higher the run expectancy of a given base-out state, the less that run expectancy correlated with the batter wOBA and the run environment.

This effect probably comes from the fact that high-scoring situations have a lot more variability in the outcomes. When there’s a lot of variability in those outcomes, the batter’s wOBA and the run environment can only do so much to predict the average. But when there’s little variability – say, bases empty with two outs, which almost always ends with no runs – the batter’s wOBA and the run environment don’t have that tough a task.

wOBA’s effect on the run expectancy is not the same across all base-out states. In addition to correlating with the goodness of fit of the regression, run expectancy also correlates with the magnitude of wOBA’s effect. This is kind of a confusing circle, because we’re talking about run expectancy’s effect on wOBA’s effect on run expectancy, which doesn’t make a whole lot of sense. But to put it simply, the coefficient by which batter wOBA is multiplied is correlated with the original run expectancy of the situation.

Only sometimes, though. Run expectancy’s correlation with wOBA’s coefficient depends heavily on how many outs there are. With no outs, there is almost no relationship between the two variables (the y-axis variable is the coefficient of wOBA in the regression):

With one out, the relationship is a bit stronger.

And with two outs, the relationship is nearly a perfect correlation.

There are two questions here: why does a higher run expectancy mean that the batter has a larger effect on the situation, and why is this phenomenon only seen with one or two outs?

For the second question, I really don’t have a great reason. But to answer the first, it’s likely because with runners on, a good hitter has the potential to do a lot of damage, whereas in lower run-producing situations, the batter can only do so much. With the bases loaded, having a .320 hitter up is much, much better than having a .230 hitter up, since you have an extra chance to drive in runs. But with the bases empty, the only difference is just an increased likelihood in a runner being on for the next guy, barring home runs.

Here’s a more specific way to visualize how wOBA’s effect changes based on the base-out state. (Click here for a larger version of the image.)

But wOBA isn’t the only variable whose effect changes with the situation. We also have the run environment. (This gets a little confusing also, since run environment and run expectancy can both be abbreviated as RE. But RE will always mean run *expectancy*.) Run environment doesn’t care as much about how many outs there are. The magnitude of its coefficient just correlates with initial run expectancy no matter what.

This means that situations in which more runs are likely to be scored benefit much more from a higher run environment than situations in which fewer runs are likely to be scored. This is, in essence, the same effect as seen with wOBA. When you’re about to score runs, it really helps to have a high run-scoring environment (or a good hitter at the plate). When you’re not about to score runs, that still helps, but not as much.

#### How to use the tool

The interactive run-expectancy tool is pretty self-explanatory. Most important are the two boxes for batter wOBA and run environment that can be adjusted to fit the situation you want.

There are also two sets of options: empirical vs. smoothed and table vs. graph. Empirical/smoothed toggles the kind of numbers that are displayed. If the empirical box is selected, you’ll see numbers from the exact situations that fit the wOBA/run environment combination you’ve selected from the dropdown menu. With that setting, extreme situations — for example, a .400 wOBA and 5 runs per game — are often not represented correctly because of sample-size issues. But with the smoothed setting on, you’ll see numbers derived from the regression equations previously discussed in this post. These are probably the better numbers to look at for any situation, not only the extreme ones.

Table vs. graph toggles how the data is shown. If the table setting is on, the run expectancy — empirical or smoothed — for the given situation is displayed. If the graph setting is on, you’ll see two bars: a gray one representing the run expectancy for that base-out state and run environment (traditional run expectancy), and a blue one representing the run expectancy for that combination of base-out state, run environment, and batter wOBA. The difference in length of the bars indicates how much higher or lower the run expectancy is with a batter of the specified wOBA at the plate than it generally is in that situation. And you can mouse over the bars to see the actual numbers.

Finally, clicking on the circles (outs) or on the bases diagram highlights that situation in the table.

Jonah is a baseball analyst and Red Sox fan. He would like it if you followed him on Twitter @japemstein, but can't really do anything about it if you don't.

wow