So back in May, I started a series of articles looking at trying to adjust pitching runs allowed for the quality of the offense the pitcher faces. Later that week, Bryan Grosnick and Blake Murphy discussed the article in the Shameless Plugs segment of our Beyond the Box Score podcast. The full discussion occurs around the 20 minute mark of the podcast, but I want to focus in on a comment that Blake made toward the end of the segment.

Hopefully the next step for him is to do this on a component basis instead of just saying this team is really good at scoring runs or this team really is bad at scoring runs.

So that's where I've decided to go with this. In a sense, we'll look at adjusting the events that a pitcher can control: walks, hit batters, home runs, and strikeouts. It happens that these statistics make up FanGraphs FIP calculation, so in addition to the adjusted components, we can get an Opponent Adjusted FIP and WAR.

### Why Do We Need To Adjust For Opponent?

We all know that sports, life — or more accurately scheduling — aren't fair. In college football, discussions of quality of opponent can help determine which teams make the National Championship Game. In the NFL, fans were furious when a 7-9 Seattle Seahawks made the playoffs by winning against an inferior division. And in baseball, we'll hear complaints about how the unbalanced schedule affects the wild card race.

It seems intuitively clear that we need to take into account who pitchers have faced during the season. A pitcher who faces a team of Miguel Cabrera or Joey Votto clones would fare much worse than if they faced a team of Alcides Escobar or Adeinny Hechavarria. It's tempting to say that all this averages itself out over time, and over an extended period of time, it might. But over the relatively brief season where a pitcher may face 1,000 batters, differences still exist.

Now, raw FIP doesn't take this into account, and xFIP doesn't take individual batters so much into account. And while the pitching WAR that is calculated from FIP does take into account league run averages and park factors, individual lineups faced isn't there either. So, in a sense, pitching WAR is the wins above a replacement player given that the replacement player faced the same schedule as the pitcher in question. But if we're comparing pitchers based on their WAR, we need to adjust for their competition to truly compare based on WAR.

That's what we'll attempt to do below. We'll assign a certain amount of blame to the pitcher based on the event and the opposition faced. Essentially, we'll cut get down to seeing how many walks, strikeouts, home runs, etc. the pitcher really allowed when the blame is taken into account. Then from this we'll calculate oaFIP and oaWAR (Opponent Adjusted FIP and WAR) in a manner very similar to the current method.

### How Do We Assign Blame

*This would be the "gory math" section. Feel free to skip to the results if you are so inclined.*

So, in order to assign the "blame" to a pitcher or hitter, we first need to start by laying some groundwork. For the sake of argument, we'll look at strikeouts only, but this exact hierarchy is applicable to walks, hit batters, and home runs. Now, for each pitcher-batter combination, the number of strikeouts in *n* at bats can be viewed as a binomial distribution. However, we are trying to determine whether the pitcher or batter should receive credit for the strikeout, so both the pitcher and batter have binomial distributions that they are able to control. So, in a sense, it is a mixture distribution of the form

P(K) = π Bin(n, θ_{Pitcher}) + (1-π) Bin(n, θ_{Batter})

where π is the probability that the blame goes to the pitcher, and θ is the strikeout rate for the pitcher or batter.

So, we need to estimate π, the probability of blame going to the pitcher, for every pitcher-batter combination that a pitcher faces. In order to do this, I decided to go the Bayesian route and create a full hierarchical model and run the MCMC associated with this. I won't explain the full thought process behind this, although I can recommend a few texts for interested people (Here for a simpler first introduction, and here for a more math-heavy look).

The full hierarchical model is given below, with the explanation of parameters given at the end.

**K _{i} | γ_{i} ∼ γ_{i} Bin(n_{i}, θ_{Pitcher}) + (1-γ_{i}) Bin(n_{i}, θ_{Batter,i})**

**γ _{i} | π ∼ Bin(1, π)**

**θ _{Pitcher} | α_{P}, β_{P} ∼ Β(α_{P}, β_{P})**

**θ _{Batter,i} | α_{B,i}, β_{B,i} ∼ Β(α_{B,i}, β_{B,i})**

Generally, we set π = 0.5, meaning that *a priori* (Before seeing the data), we don't have any information about whether the pitcher or batter receives credit for the strikeout. Also, we need to set the α and β parameters for pitcher and batter. For this, we set α = K% × 20 and β = (1 - K%) × 20 where K% is the K% for the pitcher or batter (Depending on which α and β we are calculating). This is to ensure that the expected value for θ is equal to the K% *a priori*, while simultaneously limiting the variability of θ.

In order to estimate all this, we run a Gibbs sampler on the hierarchical model, and we can estimate π_{i}^{*} by finding the proportion of draws where γ_{i} = 1. From this, we adjust the strikeouts allowed by taking K_{i}/(π_{i}^{*}/0.5), making our K_{OA} values.

Finally, to convert these components to FIP and WAR, all we need is the FIP constant. This constant will be different than the traditional FIP constant, set to be 3.048 for 2013. However, it is calculated in the exact same way, in the difference between our calculated league value and league ERA. Here, our constant is calculated to be 3.972, and the oaFIP and oaWAR are calculated in the exact same way as traditionally done.

### 2013 Leaderboard

*Okay, we're out of the "gory math."*

So, now we want to look at the leaders in oaFIP for 2013, along with the oaWAR. Without further ado, the 2013 leaderboard (For pitchers with 150 IP or more).

Player | oaFIP | oaWAR |
---|---|---|

Matt Harvey | 2.26 | 5.7 |

Anibal Sanchez | 2.70 | 4.9 |

Jose Fernandez | 2.71 | 4.2 |

Max Scherzer | 2.77 | 5.6 |

Clayton Kershaw | 2.82 | 5.2 |

Felix Hernandez | 2.93 | 4.8 |

A.J. Burnett | 2.93 | 4.1 |

Adam Wainwright | 2.96 | 5.1 |

Yu Darvish | 3.02 | 4.9 |

Cliff Lee | 3.08 | 4.5 |

Madison Bumgarner | 3.16 | 3.5 |

Francisco Liriano | 3.28 | 2.6 |

Stephen Strasburg | 3.31 | 3.1 |

Scott Kazmir | 3.34 | 2.5 |

Homer Bailey | 3.34 | 3.3 |

David Price | 3.35 | 2.8 |

Zack Greinke | 3.36 | 2.6 |

Hyun-Jin Ryu | 3.38 | 2.8 |

Mike Minor | 3.38 | 3.2 |

Ubaldo Jimenez | 3.43 | 2.7 |

Ricky Nolasco | 3.45 | 2.9 |

Chris Sale | 3.46 | 3.6 |

Cole Hamels | 3.46 | 3.2 |

Mat Latos | 3.48 | 3.1 |

Julio Teheran | 3.49 | 2.5 |

Gio Gonzalez | 3.49 | 2.8 |

Bartolo Colon | 3.52 | 2.6 |

Tim Lincecum | 3.53 | 2.4 |

Derek Holland | 3.54 | 3.3 |

Justin Verlander | 3.55 | 3.3 |

Hisashi Iwakuma | 3.57 | 3.1 |

Justin Masterson | 3.57 | 2.5 |

Rick Porcello | 3.60 | 2.5 |

Doug Fister | 3.61 | 2.9 |

Jordan Zimmermann | 3.67 | 2.5 |

Patrick Corbin | 3.69 | 2.4 |

Jered Weaver | 3.69 | 1.8 |

Jeff Samardzija | 3.70 | 2.6 |

John Lackey | 3.71 | 2.4 |

Andrew Cashner | 3.71 | 1.7 |

Eric Stults | 3.74 | 2 |

Lance Lynn | 3.76 | 2 |

Hiroki Kuroda | 3.77 | 2.5 |

Shelby Miller | 3.82 | 1.5 |

Jose Quintana | 3.83 | 2.4 |

Jhoulys Chacin | 3.83 | 2.5 |

Dan Haren | 3.85 | 1.5 |

Kris Medlen | 3.89 | 1.6 |

Jorge de la Rosa | 3.90 | 2.1 |

Jon Lester | 3.90 | 2.3 |

Edwin Jackson | 3.91 | 1.7 |

Andy Pettitte | 3.91 | 1.9 |

Felix Doubront | 3.92 | 1.7 |

Matt Garza | 3.92 | 1.5 |

James Shields | 3.93 | 2.3 |

Ervin Santana | 3.94 | 2.1 |

Scott Feldman | 3.94 | 1.7 |

Kyle Lohse | 4.01 | 1.5 |

C.J. Wilson | 4.02 | 1.5 |

Juan Nicasio | 4.03 | 1.7 |

Travis Wood | 4.03 | 1.6 |

Paul Maholm | 4.04 | 1 |

Yovani Gallardo | 4.05 | 1.3 |

Matt Cain | 4.09 | 0.9 |

Jeremy Hellickson | 4.09 | 1.1 |

Mike Leake | 4.09 | 1.2 |

Erik Bedard | 4.10 | 1.1 |

Bud Norris | 4.10 | 1.2 |

Wade Miley | 4.12 | 1.4 |

Dillon Gee | 4.18 | 0.8 |

Kyle Kendrick | 4.19 | 1 |

Kevin Correia | 4.20 | 1.1 |

Tom Milone | 4.21 | 0.8 |

Dan Straily | 4.24 | 0.7 |

Dallas Keuchel | 4.25 | 0.8 |

Edinson Volquez | 4.25 | 0.5 |

Mike Pelfrey | 4.31 | 0.4 |

Jeff Locke | 4.32 | 0.4 |

Mark Buehrle | 4.37 | 0.9 |

Chris Tillman | 4.38 | 0.9 |

C.C. Sabathia | 4.42 | 0.9 |

Jarrod Parker | 4.45 | 0.4 |

Bronson Arroyo | 4.47 | 0.4 |

A.J. Griffin | 4.48 | 0.3 |

Wily Peralta | 4.50 | 0.3 |

Ian Kennedy | 4.51 | 0.4 |

Miguel Gonzalez | 4.51 | 0.5 |

R.A. Dickey | 4.70 | 0.1 |

Joe Saunders | 4.74 | -0.1 |

Jerome Williams | 4.75 | -0.4 |

Ryan Dempster | 4.81 | -0.1 |

Jeremy Guthrie | 4.81 | -0.2 |

So we see some differences between the FanGraphs leaderboard and the one above. But the gain or loss in adjusting for opponent follows a nice distribution, with even numbers on both sides of 0.

The average difference between the two is 0.010, with the largest difference being 0.47. The pitcher who gained the most by adjusting their performance was Dan Haren, while the greatest loss fell to C.J. Wilson. And like with traditional FIP, the season of Matt Harvey leads the way as the best in the majors.

So, this is one form of adjusting for pitcher opponent ability. While it might not perfectly illuminate or eliminate the affect of opponent, this technique can help push towards making a statistic that allows for complete comparison across league and opponent.

**. . .**

** **

*FIP statistics courtesy of FanGraphs. PITCHF/x data courtesy of Baseball Heat Maps.*

*Stephen Loftus is a featured writer at Beyond The Box Score. You can follow him on Twitter at @stephen__loftus.*