O'Reilly logo

Baseball Hacks by Joseph Adler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Measure Pitching with WHIP

Measure how many base runners a pitcher allows by using WHIP.

Walks plus hits per inning pitched (WHIP) is a simple statistic for measuring pitcher effectiveness. In short, it measures the average number of base runners a pitcher allows per inning. WHIP is correlated with pitcher effectiveness, though its most important use is as a fantasy statistic (it’s actually called composite ratio in the book Rotisserie League Baseball [Bantam Books]). Here is the formula for WHIP:

	WHIP = (BB + H) / (IPOuts / 3)

Running the Hack

Summary statistics.

We’ll start with the p_and_t table from “Measure Pitching with ERA” [Hack #47] , and we’ll use this code to load the table into R (using Open Database Connectivity, or ODBC, this time):

	attach(p_and_t)
	WHIP <- (BB + H) / IPouts * 3
	p_and_t$WHIP <- WHIP

Now, let’s calculate summary statistics for consistency:

	>qualify <- IPouts > 3 * teamG
	>p_and_t$qualify <- qualify
	>summary(subset(WHIP, yearID > 1910 & qualify))
	  Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
	0.7373  1.2110  1.3090  1.3150  1.4150  1.9820

Top 10.

We’ll start with the p_and_t table from “Measure Pitching with ERA” [Hack #47] , and we’ll use this SQL code to calculate the top 10 players of all time, by WHIP:

 select f.franchName as Team, concat(m.nameLast, ", ", m.nameFirst, " (", p.yearID, ")") as Player, round((p.H + p.BB)/p.IPOuts * 3,3) as WHIP, p.IPOuts from p_and_t p inner join master m inner join teamsFranchises f where substring(p.teamIDs,1,3)=f.franchID and p.idxLahman=m.idxLahman ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required