Tools: Installing MySQL on OS X

If you’ve ever installed MySQL on Linux, you know how easy it is. If you’ve ever installed MySQL on OS X, you know what a terrible pain-in-the-ass it is. It’s a pain whether you install the latest package directly from, or if you install via macports. In order to actually make it work there are about a half dozen post-installation steps you need to follow, none of which are documented anywhere reasonable.

Enter the lovely folks a Mac Mini Vault. They have created and published (via GitHub) a script that installs MySQL from beginning to end, along with several other useful scripts.

If you’re a Mac user and you want to use MySQL for sabermetric analysis, save yourself some headaches and use the script.


Situational Fastball Usage

In a comment on my THT article on pitch sequencing, MGL made the following observation:

One other thing that must be controlled for is game situation and that could be significantly affecting the results. For example, when the pitching team is ahead, especially way ahead, later in the game, the pitcher is more likely to throw a fastball on all pitches, more likely to throw a strike, etc. The batting team is more likely to be taking more pitches, etc.

Unsurprisingly given the source, this is absolutely correct!

To test MGL’s assertion, I computed the percentage of fastball variants (FF, FA, FT, FC, FS, SI in PITCHf/x) thrown by every pitcher from 2008-2014, broken out by platoon, inning, count, index (i.e. whether the pitch was the 1st, 2nd, 3rd, etc. of the PA), and run differential (i.e. how many runs ahead or behind their team was at the time). I then used the delta method to compare (a) the percentage of fastballs thrown in the 7th inning or later when the pitcher’s team was ahead by 4 or more runs, to (b) the percentage of fastballs thrown in the 7th inning or later when the run differential was between 1 and -1.

Here are some selected findings:

  • On the first pitch, pitchers threw fastballs at a 5.2% higher rate when far ahead
  • On the second pitch (ignoring count), pitchers threw fastballs at a 1.5% higher rate when far ahead
  • Irrespective of count or pitch index, pitchers threw fastballs at a 3.6% higher rate overall when far ahead
  • In 1-0 counts, pitchers threw fastballs at a 6.7% higher rate when far ahead
  • In 0-1 counts, pitchers threw fastballs at a 2.8% lower rate when far ahead

In deeper counts the sample sizes quickly get small, so I’ll stop at 1-0 and 0-1. But the results are definitive: pitchers lean more on their fastball late in games when their team is far ahead. The astute reader will note that pitchers threw fastballs less frequently in 0-1 counts when far ahead (this is also the case for 1-1 and 0-2 counts, in smaller samples), but that is not enough to offset the higher fastball rates in other counts.

In fact the effect shows up whenever the pitcher’s team is far ahead, not just late in games. In innings 4 through 6 pitchers threw fastballs at a 4.1% higher rate on the first pitch, and a 2.3.% higher rate overall, when far ahead than in close games.

So MGL’s observation is exactly right: to really do this kind of pitch-level analysis correctly, we need to control for much more than I did in my last article.