tag:blogger.com,1999:blog-60053651671823515592014-10-03T01:12:16.676-04:00Statistics in BaseballDavid Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-6005365167182351559.post-33968186428002975332010-10-19T18:04:00.000-04:002010-10-19T18:04:23.707-04:00Big changes!I've got a great new job, starting in January, for a sports betting company in London. This means that the blog entries will probably stop for good because my baseball modelling efforts will go into the job. I may still post once in a while about other sports that my employers don't bet on - like maybe curling!David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-62664698723707546462010-10-11T00:01:00.000-04:002010-10-19T17:46:07.983-04:00The Home Run Derby effect?Do players who participate in the All-Star Game Home Run Derby screw up their swing, go into a slump, and have a poor second half? I've heard this one from the talking heads before, and it sounds completely false to me. Mark McGwire used to put on a show in batting practice in 1998, and it didn't stop him from hitting 70 home runs.<br /><br />The Home Run Derby data were found from the <a href="http://mlb.mlb.com/mlb/history/hr_derby.jsp">MLB website</a>, but they weren't in CSV or tab separated format, so I had to do some manipulation. I would have liked to get data on just the few games following the HR Derby to check for slumps, but I settled for the first and second half splits (as determined by the All-Star break) from <a href="http://www.baseball-reference.com/">Baseball-Reference</a>. I used the years 2003-2009.<br /><br />OPS is a good measure of how effective a hitter is, so I thought it would be best to compare pre- and post-break numbers in terms of OPS (I tried some other things and they led to similar conclusions). Baseball-Reference has a statistic called sOPS+ which measures a player's OPS relative to the league. This controls for season, but since I was looking at first and second half differences, this wasn't too important. I tried it anyway, and it gave almost the exact same results as OPS, so I stuck with OPS.<br /><br />Although some players appeared in more than one HR Derby between 2003 and 2009, I assumed that the 56 differences between pre-break OPS and post-break OPS were independent. The differences looked Gaussian, and the average pre-break OPS was .958 and the average post-break OPS was .924, leading to a one-sided p-value of 0.02 in the paired t-test - so it's true, the participants do worse after the break! This idea is furthered by the fact that the mean career pre- and post-break OPS for the players are not significantly different - the decrease seems to happen specifically in the year the players compete in the HR Derby.<br /><br />But... how are hitters selected for the HR Derby? By having a very good first half. The hitters participating are ones who have often done unusually well in the first half, and were heading for a drop-off in the second half whether they took part in the derby or not. I can think of two ways to get around this and answer the question of whether the HR Derby <span style="font-style: italic;">causes</span> the poorer second half. One is to compare the second half OPS in HR Derby years to the second half OPS in non-HR Derby years, and the other is to see if players who take part in more rounds of the derby have a bigger second half drop-off than players who are eliminated early. (I could also look at the second half drop-off for players in the All-Star Game who weren't in the HR Derby, but it was enough of a pain getting the data for just these players, so I'll try to avoid this approach.)<br /><br />The mean career second half OPS of the 56 HR Derby hitters is .894, and in HR Derby years it is .924. This is still a bit unsatisfactory because the HR Derby year is presumably in the prime of their career, so let's try the second way. Consider the number of swings taken in the competition by each player; this is equal to ten times the number of rounds they were in, plus their HR total. Fitting a linear regression of decrease in OPS on number of HR Derby swings, it is apparent that the more swings the player takes, the less the pre- and post-break OPS difference is, i.e. the opposite of the proposed effect. So I'm pretty comfortable writing the poorer second halves off to selection bias.<br /><br />Thanks to Bret Hanlon for the idea for this post.David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-73789391443395354012010-10-10T00:01:00.001-04:002010-10-23T07:55:16.009-04:00Starting pitchers in their last inning of the gameIn my <a href="http://statisticsinsports.blogspot.com/2010/08/when-to-remove-starting-pitcher.html">previous post</a> I compared the FIP for starting pitchers in their final inning of the game to the FIP of their team's bullpen, and found that they're being left in the game too long. Today I'm just going to present three tables that I created from the R code used to make that post. I limited the data to the AL in 2009 in the previous post because the bullpen data had to be collated manually, but no such barrier exists this time, so I used both the AL and NL from 2002-2009, limiting the data to pitchers who started at least 50 games over that time.<br /><br />This first table looks at pitchers who had the most significant drop-off (all of them had p-values less than 10^(-6)) from their non-final inning numbers to their final inning numbers. 233 of the 241 of the pitchers in the sample had a significant drop-off (p-values less than 0.05), but these were the most severe. I don't know how much this difference really means because the important number for managerial decisions is the late FIP, but many of these guys are good pitchers, and are probably pitching in close games pretty often (unlike somebody who has a really high FIP throughout the game), and their team would benefit if the manager got them out one inning early. Of course knowing when the pitcher is going to start getting knocked around in a given game is impossible - sometimes they might be getting pulled in the 8th, other times in the 7th, etc. However it seems managers should be extra aware about these pitchers, and get them out of the game as soon as they're showing even a slight decrease in velocity.<br /><table align="center" border="1"><tbody><tr><th align="middle">pitcher</th><th align="middle">early FIP </th><th align="middle">late FIP </th></tr><tr><td align="middle">Burnett, A.J.<br /></td><td align="middle">3.351</td><td align="middle">5.907</td></tr><tr><td align="middle">Byrd, Paul<br /></td><td align="middle">4.182</td><td align="middle">7.196</td></tr><tr><td align="middle">Fogg, Josh<br /></td><td align="middle">4.529</td><td align="middle">8.090</td></tr><tr><td align="middle">Garland, John<br /></td><td align="middle">4.210</td><td align="middle">7.301</td></tr><tr><td align="middle">Hernandez, Livan<br /></td><td align="middle">4.039</td><td align="middle">6.670</td></tr><tr><td align="middle">Lackey, John<br /></td><td align="middle">3.538</td><td align="middle">5.755</td></tr><tr><td align="middle">Lohse, Kyle<br /></td><td align="middle">4.332</td><td align="middle">7.152</td></tr><tr><td align="middle">Meche, Gil<br /></td><td align="middle">3.940</td><td align="middle">6.950</td></tr><tr><td align="middle">Ortiz, Russ<br /></td><td align="middle">4.183</td><td align="middle">7.639</td></tr><tr><td align="middle">Pavano, Carl<br /></td><td align="middle">3.536</td><td align="middle">7.049</td></tr><tr><td align="middle">Perez, Oliver<br /></td><td align="middle">4.176</td><td align="middle">7.506</td></tr><tr><td align="middle">Robertson, Nate<br /></td><td align="middle">4.160</td><td align="middle">7.473</td></tr><tr><td align="middle">Santana, Johan<br /></td><td align="middle">2.915</td><td align="middle">5.337</td></tr><tr><td align="middle">Silva, Carlos<br /></td><td align="middle">4.143</td><td align="middle">7.384</td></tr><tr><td align="middle">Trachsel, Steve<br /></td><td align="middle">4.444</td><td align="middle">7.597</td></tr><tr><td align="middle">Wakefield, Tim<br /></td><td align="middle">4.149</td><td align="middle">7.193</td></tr></tbody></table><br /><br />This table is less interesting, but these were the only eight pitchers who didn't have a significant last inning FIP increase.<br /><table align="center" border="1"><tbody><tr><th align="middle">pitcher</th><th align="middle">early FIP </th><th align="middle">late FIP </th><th align="middle">p-value </th></tr><tr><td align="middle">Williams, David<br /></td><td align="middle">5.131</td><td align="middle">6.063</td><td align="middle">0.187</td></tr><tr><td align="middle">Smoltz, John<br /></td><td align="middle">3.114</td><td align="middle">3.827</td><td align="middle">0.089</td></tr><tr><td align="middle">Litsch, Jesse<br /></td><td align="middle">4.510</td><td align="middle">5.820</td><td align="middle">0.085</td></tr><tr><td align="middle">Ryan, Brendan<br /></td><td align="middle">4.148</td><td align="middle">5.208</td><td align="middle">0.073</td></tr><tr><td align="middle">Kuroda, Hiroki<br /></td><td align="middle">3.400</td><td align="middle">4.561</td><td align="middle">0.071</td></tr><tr><td align="middle">Santos, Victor<br /></td><td align="middle">4.556</td><td align="middle">5.713</td><td align="middle">0.066</td></tr><tr><td align="middle">Galarraga, Armando<br /></td><td align="middle">4.760</td><td align="middle">6.435</td><td align="middle">0.056</td></tr><tr><td align="middle">Hammel, Jason<br /></td><td align="middle">3.976</td><td align="middle">5.410</td><td align="middle">0.050</td></tr></tbody></table><br /><br />The final table shows the nine pitchers who had a last inning FIP over 9.00. I don't think any of them are still starting games. Rick Reed had a good career and my data set just caught the tail end of it. Most have been tried as relief pitchers, and Darren Oliver has actually become a pretty good one.<br /><table align="center" border="1"><tbody><tr><th align="middle">player</th><th align="middle">early FIP </th><th align="middle">late FIP </th></tr><tr><td align="middle">James, Chuck<br /></td><td align="middle">4.240</td><td align="middle">10.827</td></tr><tr><td align="middle">McClung, Seth<br /></td><td align="middle">4.669</td><td align="middle">10.280</td></tr><tr><td align="middle">Oliver, Darren<br /></td><td align="middle">5.053</td><td align="middle">9.661</td></tr><tr><td align="middle">Kinney, Matt<br /></td><td align="middle">4.037</td><td align="middle">9.640</td></tr><tr><td align="middle">Waechter, Doug<br /></td><td align="middle">4.830</td><td align="middle">9.609</td></tr><tr><td align="middle">Reed, Rick<br /></td><td align="middle">3.531</td><td align="middle">9.534</td></tr><tr><td align="middle">Helling, Rick<br /></td><td align="middle">4.162</td><td align="middle">9.433</td></tr><tr><td align="middle">Owings, Micah<br /></td><td align="middle">4.872</td><td align="middle">9.243</td></tr><tr><td align="middle">Mays, Joe<br /></td><td align="middle">4.595</td><td align="middle">9.032</td></tr></tbody></table><br /><br /><span style="font-family:monospace;"><span style="font-weight: bold;">The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-50014476409875728712010-09-01T00:01:00.001-04:002010-10-23T07:54:06.907-04:00When to remove the starting pitcherI've always thought managers are slow to go to the bullpen. It seems like they usually wait for the starting pitchers to get into trouble instead of trying to get them out before trouble starts, so I decided to look at the data. My strategy was to compare the last inning of starting pitching to the bullpen's average numbers, and look for significant differences. Getting bullpen numbers for each team isn't easy, and I had to copy/paste each team individually from different pages at <a href="http://www.baseball-reference.com/">Baseball-Reference</a> - not wanting to do this for a bunch of different seasons, I just used the 2009 AL numbers. I would speculate that the NL managers are a bit better at pulling the starter because sometimes they are nudged to do so when he comes up to bat. As it turns out, using only 2009 gives plenty of data to see that managers do not pull the starters in a timely manner. In fact, for all 14 teams there is a significant difference between the bullpen and the last inning of their starting pitching.<br /><br />Rather than using ERA to compare SPs and RPs, I used <a href="http://en.wikipedia.org/wiki/Defense_independent_pitching_statistics#FIP">FIP</a>. I added HBP to BB in this formula. The additive term seems to have changed from 3.20 to 3.10 since I wrote my <a href="http://statisticsinsports.blogspot.com/2009/11/closers-in-non-save-situations.html">entry on closers</a>. The advantage of using FIP is twofold: it takes a lot of the luck out of the equation, and actually predicts future ERA better than past ERA does; and inherited runners are not important because we're just considering HR, BB, K, and IP. It's easy to estimate the standard deviation of FIP because it can be written as a function of multinomial probabilities. This is important here because I want to be able to tell if the bullpen's FIP is <span style="font-style: italic;">significantly</span> better than the starters' FIP.<br /><br />I limited the data to pitchers who started at least 15 games (64 pitchers qualify), figuring by that point the manager should have a good idea of when the pitcher is tiring. Of course I have the advantage of looking at the whole season's data to see where the differences lie - at the beginning of the season, the manager may not know how good his bullpen will be, or how his new pitchers behave in the late innings, etc. But as we'll see from the huge differences - SPs should be removed sooner rather than later!<br /><br />The following table shows the team's average SP FIP for their last inning in the second column, the bullpen's FIP in the third column, and the p-value testing whether RP FIP is less than SP FIP in the final column.<br /><table align="center" border="1"><tbody><tr><th align="center">team</th> <th align="center"> SP FIP </th><th align="center"> RP FIP </th> <th align="center"> p-value </th></tr><tr><td align="center">ANA</td><td align="center">7.278</td><td align="center">4.274</td><td align="center">0.000</td></tr><tr><td align="center">BAL</td><td align="center">7.522</td><td align="center">4.557</td><td align="center">0.001</td></tr><tr><td align="center">BOS</td><td align="center">6.334</td><td align="center">4.154</td><td align="center">0.001</td></tr><tr><td align="center">CHA</td><td align="center">7.209</td><td align="center">3.927</td><td align="center">0.000</td></tr><tr><td align="center">CLE</td><td align="center">7.851</td><td align="center">4.686</td><td align="center">0.000</td></tr><tr><td align="center">DET</td><td align="center">6.173</td><td align="center">4.666</td><td align="center">0.024</td></tr><tr><td align="center">KCA</td><td align="center">6.737</td><td align="center">4.586</td><td align="center">0.003</td></tr><tr><td align="center">MIN</td><td align="center">9.148</td><td align="center">4.322</td><td align="center">0.000</td></tr><tr><td align="center">NYA</td><td align="center">5.438</td><td align="center">4.329</td><td align="center">0.044</td></tr><tr><td align="center">OAK</td><td align="center">6.265</td><td align="center">3.349</td><td align="center">0.000</td></tr><tr><td align="center">SEA</td><td align="center">5.673</td><td align="center">4.352</td><td align="center">0.046</td></tr><tr><td align="center">TBA</td><td align="center">7.011</td><td align="center">4.487</td><td align="center">0.002</td></tr><tr><td align="center">TEX</td><td align="center">6.402</td><td align="center">4.057</td><td align="center">0.000</td></tr><tr><td align="center">TOR</td><td align="center">8.500</td><td align="center">4.211</td><td align="center">0.000</td></tr></tbody></table><br />Joe Girardi of the Yankees and Don Wakamatsu of the Mariners were the best at removing their starters before they got knocked around. But they still seem to leave them in too long, and actually they might only be the best because both teams had four qualifying SP, all of whom were pretty good - notice they have the best SP numbers of any teams.<br /><br />Most teams actually have slightly better RP numbers than SP numbers (even when removing the last inning pitched for all the SP); I guess this is due to being able to throw harder when you throw fewer pitches (I've also heard pitchers are worse the second time through the order - something to investigate in the future). The differences are quite small, but still, if the managers are aware of this, maybe their bullpens are already operating at their innings limit, and can't come in one inning earlier. Or at least all their good RP are operating at their innings limit. I bet some of the difference that shows up in the table is unavoidable, but it sure seems like it would help to have your best AAA pitcher on the roster, instead of another backup hitter, to eat up some of the bad SP innings.<br /><br />Next time I'll look at some of the pitchers who have the biggest dropoff in FIP from the first several innings to their final inning and at the ones who are the worst in their final inning. Without needing bullpen average FIPs here, I'll be able to consider several seasons at once.<br /><br /><br /><span style="font-family:monospace;"><span style="font-weight: bold;">The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-4434571325507843352010-08-01T00:01:00.000-04:002010-10-19T17:46:08.037-04:00Do knuckleballers induce slumps?The <a href="http://en.wikipedia.org/wiki/Knuckleball">knuckleball</a> is a very unusual pitch. It's thrown significantly slower than every other pitch, and it's been said to mess with a hitter's timing. Hitters seem to do fine against the knuckleball (KB), but I've heard people say that they'll go into a slump after facing the knuckler. Today I thought I'd investigate. Retrosheet's game logs provide the starting pitcher for every game as well as the basic offensive statistics needed to compute on-base percentage (OBP) and slugging percentage (SLG), so getting data was easy.<br /><br />I picked out six knuckleballers, either famous or contemporary: Tom Candiotti, Charlie Hough, Steve Sparks, Tim Wakefield, Phil Niekro, and Hoyt Wilhelm. There are some other famous ones, like Joe Niekro, but they didn't throw it for their whole career. I searched through the data to find any games that one of these pitchers started, and then looked at their opponent's OBP and SLG in their <span style="font-style: italic;">k</span>th game after the knuckler game (<span style="font-style: italic;">k</span>=1,...,3 is all that was needed), and paired that with the team's average OBP and SLG over the whole season, with the intention of studying the paired differences to look for a post-KB game effect. I assumed that the differences were independent - which is at least approximately true.<br /><br />To calculate the team's overall strength I had to use the unweighted average OBP and SLG, i.e. I averaged the OBP and SLG from all 162 games rather than adding all the count data together to find the weighted average. This was necessary because the weighted average tends to be higher than the value for a single game.<br /><br />The differences between the season average and the <span style="font-style: italic;">k</span>th game average have a beautiful bell-shaped curve (for both OBP and SLG), so I used two paired t-tests to see if the differences were significantly greater than zero. Since each difference is actually based on the difference of two averages, both of which might have a slightly different sample size each time (at-bat totals won't be exactly the same every game), I could probably be more efficient by assigning some weights to the differences, but I highly doubt this would make a non-negligible difference in the p-values.<br /><br />The third column in the following two tables shows the <span>average for the <span style="font-style: italic;">k</span>th</span> game after the knuckleball game, <span style="font-style: italic;">k</span>=1,...,3, with the average season total for the teams in the sample in the second column. The p-values are testing OBP>post-KB OBP and SLG>post-KB SLG respectively, and they are based on a paired t-test.<br /><br /><table align="center" border="1"><tbody><tr><th align="center">game</th> <th align="center"> OBP </th><th align="center"> post-KB OBP </th> <th align="center"> p-value </th></tr><tr><td align="center">1</td><td align="center">0.3206</td><td align="center">0.3195</td><td align="center">0.2566</td></tr><tr><td align="center">2</td><td align="center">0.3206</td><td align="center">0.3226</td><td align="center">0.8676</td></tr><tr><td align="center">3</td><td align="center">0.3206</td><td align="center">0.3198</td><td align="center">0.3233</td></tr></tbody></table><br /><table align="center" border="1"><tbody><tr><th align="center">game</th> <th align="center"> SLG<br /></th><th align="center"> post-KB SLG </th> <th align="center"> p-value </th></tr><tr><td align="center">1</td><td align="center">0.3934</td><td align="center">0.3869</td><td align="center">0.0174</td></tr><tr><td align="center">2</td><td align="center">0.3934</td><td align="center">0.3939</td><td align="center">0.5696</td></tr><tr><td align="center">3</td><td align="center">0.3934</td><td align="center">0.394</td><td align="center">0.5872</td></tr></tbody></table><br /><br />The knuckleball actually does seem to sap the team's power the day after they face it. Actually most of the next day woes are due to Candiotti's and Wakefield's effects, in particular Wakefield's. His tables are below:<br /><br /><table align="center" border="1"><tbody><tr><th align="center">game</th> <th align="center"> OBP </th><th align="center"> post-KB OBP </th> <th align="center"> p-value </th></tr><tr><td align="center">1</td><td align="center">0.3261</td><td align="center">0.3163</td><td align="center">0.0093</td></tr><tr><td align="center">2</td><td align="center">0.3261</td><td align="center">0.3256</td><td align="center">0.4509</td></tr><tr><td align="center">3</td><td align="center">0.3261</td><td align="center">0.3224</td><td align="center">0.1968</td></tr></tbody></table><br /><table align="center" border="1"><tbody><tr><th align="center">game</th> <th align="center"> SLG<br /></th><th align="center"> post-KB SLG </th> <th align="center"> p-value </th></tr><tr><td align="center">1</td><td align="center">0.4164</td><td align="center">0.3958</td><td align="center">0.0021</td></tr><tr><td align="center">2</td><td align="center">0.4164</td><td align="center">0.4168</td><td align="center">0.5205</td></tr><tr><td align="center">3</td><td align="center">0.4164</td><td align="center">0.4081</td><td align="center">0.1328</td></tr></tbody></table><br /><br />The overall effects are higher in Wakefield's tables because he's pitched in an offensive era. Hitters really do seem significantly worse than normal the day after they face him - even with the <a href="http://en.wikipedia.org/wiki/Bonferroni_correction">Bonferroni correction</a>, the SLG decrease is significant, and the OBP decrease is marginally significant. The unweighted averages of OBP and SLG are .316 and .398 in games Wakefield pitches - actually quite close to the averages of the opposing team on the following day, and both lower than the overall average. Hough, Niekro, and Wilhelm are the superior pitchers, but maybe they didn't throw the knuckler as often as Wakefield does, and hence don't screw up the hitters' next day timing as much? Or maybe it has something to do with contemporary hitters not seeing the knuckler as often as guys in the past may have? Steve Sparks doesn't cause this next day drop-off though.<br /><br /><br /><br /><span style="font-family:monospace;"><span style="font-weight: bold;">Thanks to <a href="http://www.stat.duke.edu/%7Ebs128/">Ben Shaby</a> for suggesting this idea. </span></span><span style="font-family:monospace;"><span style="font-weight: bold;">The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".<br /></span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com2tag:blogger.com,1999:blog-6005365167182351559.post-23767657051160342062010-07-17T12:08:00.001-04:002010-10-23T07:52:28.204-04:00Late-inning defensive substitutionsSometimes a manager will remove a poor fielder from the game when his team is winning, believing the defensive improvement is enough to offset the loss of this player's bat. This usually happens in the 9th inning. Here's a short discussion about it: <a href="http://www.insidethebook.com/ee/index.php/site/article/late_inning_fielding_replacement/">Tango analysis</a>. My plan was to consider the following:<br /><ul><li>win: a binary response for logistic regression indicating if the team held on to win the game,</li><li>I.def: an indicator of whether the player was substituted for,</li><li>dist: the number of spots in the order until this player is due to bat again. Presumably as this increases, the defensive substitution starts to look better and better,</li><li>lead: either one or two runs,</li><li>inn: inning - limited to top of the 9th and bottom of the 9th. I didn't want to include the 8th and get into dealing with players who weren't replaced in the 8th but then were in the 9th. The replacement usually happens in the 9th inning anyway,<br /></li><li>player: identity of the original player, much like the pinch running analysis, I'm going to lump all the replacements together,</li><li>opp: the opposing team,<br /></li></ul>and to limit the analysis to the AL games to avoid the implications of double switches that happen only in the NL.<br /><br />To lead into my (short) analysis, I want to continue the selection bias discussion from my <a href="http://statisticsinsports.blogspot.com/2010/07/are-pinch-runners-effective-part-3-of-3.html">previous post</a>. In that situation, requiring all four pairwise combinations of win/loss with pinch runner/no pinch runner to exist for each player created a selection bias and led to an overestimate of the PR main effect. I don't think it affected the analysis very much because my interest was in estimating the sum of this main effect and the average player:PR interaction for 25 good hitters, and this sum should not be affected by a biased main effect - the sum for an individual player estimates his personal PR effect and this is not dependent on any bias in the estimate of the average.<br /><br />In today's analysis I am looking at defensive replacement by teams in the lead, so they go on to win the game - with or without the replacement - a vast majority of the time. Hence, if I set up the model in the same way as I set up the pinch runner model, with win as the response in a logistic regression, this selection bias will be quite severe. The pairwise combination most often lacking is the loss/replacement, and so many players whose replacement only ever led to victory get deleted from the sample. Proceeding as if everything was normal leads to a hugely negative defensive replacement main effect. Again my interest would be in the sum of this effect and the interaction effects of good hitters, so this is not an insurmountable obstacle.<br /><br />The obstacle seems to be the lack of repetitions. I was picturing managers replacing their good hitters in close games all the time, and then when extra innings roll around, being left without their good hitters. But as an exploratory analysis I looked at 25 years of data, limited to players hitting in the top five in the order (lower than that the replacement might well be as good as the guy he's replacing) who've been substituted for in the 9th inning with a one or two run lead at least one time (not imposing any condition on having lost at least one game, and so unable to estimate a player effect), and found that out of the 36844 cases remaining, only 629 were defensive replacements - this amounts to less than 2 substitutions per season per team. And of those 36844, only 1490 times did their spot come to bat again - 1428 times with them in it, and 62 times with their replacement in it. At least you'd think that the team wins more often when the player hasn't been replaced, right? 657 wins/1428 games (46%) batting for himself, and 30 wins/62 games (48%) with the replacement - a statistically insignificant difference. Unsurprisingly, when I fit the full logistic regression model described above (again I limited to the top five in the order and fit without player:I.def interaction), the I.def effect was not anywhere close to significant.<br /><br />This brute force approach to try to get around the noisy data is not going to work here. It certainly looks like the defensive replacement effect, if any, is quite minimal anyway. I'm satisfied for now, but to answer the question properly, I'd have to be able to measure exactly how much a defensive replacement helps the defense, and I don't have the data to do that right now.<br /><br /><br /><span style="font-family:monospace;"><span style="font-weight: bold;">The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-38177293558469878532010-07-04T13:14:00.001-04:002010-10-23T07:51:10.854-04:00Are pinch runners effective? Part 3 of 3In this entry I'm going to see whether pinch running is a good tradeoff: increasing the probability of scoring by enough to offset the loss of offense in extra innings. My <a href="http://statisticsinsports.blogspot.com/2010/07/are-pinch-runners-effective-part-2-of-3.html">previous post</a> saw how much pinch running helped the chances of scoring - it was more than I thought. Now we'll complete the second half of the problem.<br /><br />My original plan was to look only at future innings where the PR (or original hitter if he wasn't pinch run for) came to bat. This would decrease the variance inevitably created by considering opponents' runs or runs in innings when this spot didn't come to bat. Then by finding the probability of this spot returning to the plate in each different situation, I could isolate the negative side of the PR effect, which could then be combined with the estimate of the positive side that I already have. I was hoping this would let me separate the effects of pinch running and the defensive replacement that surely occurs along with it, but these probabilities of returning to bat are going to depend on the opponent's run scoring and this depends a bit on the defense. The main problem though, would be to connect these separate analyses of the good and the bad of pinch running with a sensible variance estimate that allows for the dependence between the two models.<br /><br />So I scrapped this idea and decided to start by just fitting a multiple logistic regression with win/loss as the binary response, hoping that the noisiness of the data would be offset by the fact that I had the data for games all the way back to 1952. The predictors I considered were:<br /><ul><li>I.PR: an indicator of whether there was a pinch runner,</li><li>lead: the score difference between the two teams (either -1, 0, or 1),</li><li>inn: either top 8th, bottom 8th, top 9th, or bottom 9th. I lumped extra innings in with the 9th inning,<br /></li><li>outs: the number of outs when the runner first got on base (this is categorical because there's no reason outs would be related linearly to the log odds of scoring),</li><li>I.2nd: an indicator of whether the runner was on 2nd base (the alternative is the reference level, 1st base),</li><li>player: identity of the original runner (for parsimony I'm lumping all pinch runners together as being fast guys),</li><li>opp: the opposing team. This doesn't make much difference because unless you're going to control for which pitcher you're facing, the variance in opposition even within the same team is pretty big due to different pitchers across different generations.<br /></li></ul>I looked at data for the past 20 years (1990-2009). I used sum contrasts for players (so the average player would have a zero estimate for his effect) and treatment contrasts for all the other predictors. The significant interactions were I.PR:lead, inn:lead, outs:lead, and I.2nd:outs. Notice that there is no data for bottom9th:lead1, so this did not have an estimate; however, that did not preclude proper estimation of the remaining inn:lead effects. This time I wanted to include the I.PR:player interaction because this helps measure exactly what I want to know. Before explaining why this is so, it's best to explain the meaning of the main effects.<br /><br />The main effect of player measures mostly how good his team is, particularly the players hitting immediately after him. A player effect of zero means his team is about average. The main effect of I.PR measures how much pinch running for the average player increases the log odds of winning. Note that this "average" is not the same as the other one: this one refers more to the speed of player himself. It also incorporates how good a hitter he is - because he might return to the plate in extra innings - but as we will see, it's mostly about his speed, just as the player main effect is mostly about his team rather than himself.<br /><br />But the interaction of I.PR and player provides information about pinch running for this player relative to the average; if it's positive, a PR should be employed for this player at least as often as the average player; if it's negative, the PR should be employed less often than the average. In fact if the sum of the interaction coefficient and the I.PR coefficient is negative, the log odds of winning the game are decreased when the player is pinch run for.<br /><br />(Aside: the minor selection bias I mentioned in part 2 is exacerbated here. To estimate the player:I.PR interaction, we need all four pairwise combinations of win/loss with PR/no PR for each player, so any player who is lacking one of these combinations is deleted. By far the most likely to be missing are the two involving PR. About 55% of these deletions were loss/PR - a higher percentage of losses than the true PR population contains - so the PR main effect in my analysis has a positive bias. But my goal is to look at player-specific PR effects, and those are based on the sum of the PR main effect with the interaction term, a sum which should be invariant to any bias in the main effect - if the main effect is too high, the interaction estimate will just be lower to balance it out. I wouldn't expect the parameter estimates for the effects not involving PR to be biased.)<br /><br />I don't want to consider just one player at a time because the variance of the interaction coefficient estimates is too large to make an informed conclusion. But what I can do is average the interaction effects of many players together. Without looking at the data, I picked a list of 25 players who I thought were good hitters, but in general pretty slow runners:<br /><ul><li>Berkman, Lance</li><li>Bonds, Barry</li><li>Cabrera, Miguel</li><li>Dunn, Adam</li><li>Giambi, Jason</li><li>Guerrero, Vladimir</li><li>Gwynn, Tony</li><li>Helton, Todd</li><li>Holliday, Matt</li><li>Howard, Ryan</li><li>Jones, Chipper</li><li>Kent, Jeff</li><li>Lee, Carlos</li><li>McGriff, Fred</li><li>McGwire, Mark</li><li>Ordonez, Magglio</li><li>Ortiz, David</li><li>Palmeiro, Rafael</li><li>Piazza, Mike</li><li>Ramirez, Manny</li><li>Rodriguez, Ivan</li><li>Sheffield, Gary</li><li>Sosa, Sammy</li><li>Thomas, Frank</li><li>Youkilis, Kevin</li></ul>Most of these guys have been pinch run for tens of times, and not pinch run for over 100 times. If their average interaction coefficient estimate was significantly negative, that would tell me they should be pinch run for at least as often as the average player. (I'm being vague because we don't know yet if the average player should be pinch run for.) But their average I.PR:player coefficient estimate is 0.26 with a standard error of 0.18. I guess I could take an even larger sample of good, slow hitters, but even with the big standard error, I'm convinced that this interaction estimate has a lot more to do with speed than hitting ability - the results from part 2 really did show that having a PR helps a lot. The estimate of the main effect of PR is also positive, but as I mentioned earlier, it's biased, so I won't draw any conclusions about the average players here (I did do a separate analysis without interaction, and hence without a noticeable selection bias, and the PR effect for the average player was still significant).<br /><br />The table below is based on the average of the 25 aforementioned players. It gives the probabilities of winning in each of the 66 different situations (don't worry, I used a loop in R to make the html code so I didn't have to type it all). The situation column is as follows: lead, inning, base, outs. The p-values are for the 2-sided test between the two probability estimates.<br /><br /><table align="center" border="1"><tbody><tr><th align="center">situation</th> <th align="center"> P(win) no PR </th><th align="center"> P(win) PR </th> <th align="center"> p-value </th></tr><tr><td align="center">-1,t8,1,0</td><td align="center">0.325</td><td align="center">0.379</td><td align="center">0.217</td></tr><tr><td align="center">-1,t8,1,1</td><td align="center">0.232</td><td align="center">0.277</td><td align="center">0.226</td></tr><tr><td align="center">-1,t8,1,2</td><td align="center">0.145</td><td align="center">0.177</td><td align="center">0.236</td></tr><tr><td align="center">-1,t8,2,0</td><td align="center">0.399</td><td align="center">0.457</td><td align="center">0.210</td></tr><tr><td align="center">-1,t8,2,1</td><td align="center">0.290</td><td align="center">0.341</td><td align="center">0.221</td></tr><tr><td align="center">-1,t8,2,2</td><td align="center">0.156</td><td align="center">0.190</td><td align="center">0.235</td></tr><tr><td align="center">-1,b8,1,0</td><td align="center">0.442</td><td align="center">0.501</td><td align="center">0.206</td></tr><tr><td align="center">-1,b8,1,1</td><td align="center">0.332</td><td align="center">0.386</td><td align="center">0.217</td></tr><tr><td align="center">-1,b8,1,2</td><td align="center">0.218</td><td align="center">0.261</td><td align="center">0.228</td></tr><tr><td align="center">-1,b8,2,0</td><td align="center">0.521</td><td align="center">0.580</td><td align="center">0.200</td></tr><tr><td align="center">-1,b8,2,1</td><td align="center">0.401</td><td align="center">0.459</td><td align="center">0.210</td></tr><tr><td align="center">-1,b8,2,2</td><td align="center">0.233</td><td align="center">0.278</td><td align="center">0.227</td></tr><tr><td align="center">-1,t9,1,0</td><td align="center">0.216</td><td align="center">0.259</td><td align="center">0.227</td></tr><tr><td align="center">-1,t9,1,1</td><td align="center">0.148</td><td align="center">0.180</td><td align="center">0.234</td></tr><tr><td align="center">-1,t9,1,2</td><td align="center">0.089</td><td align="center">0.110</td><td align="center">0.240</td></tr><tr><td align="center">-1,t9,2,0</td><td align="center">0.275</td><td align="center">0.325</td><td align="center">0.222</td></tr><tr><td align="center">-1,t9,2,1</td><td align="center">0.190</td><td align="center">0.229</td><td align="center">0.230</td></tr><tr><td align="center">-1,t9,2,2</td><td align="center">0.096</td><td align="center">0.118</td><td align="center">0.240</td></tr><tr><td align="center">-1,b9,1,0</td><td align="center">0.296</td><td align="center">0.348</td><td align="center">0.219</td></tr><tr><td align="center">-1,b9,1,1</td><td align="center">0.209</td><td align="center">0.251</td><td align="center">0.228</td></tr><tr><td align="center">-1,b9,1,2</td><td align="center">0.129</td><td align="center">0.158</td><td align="center">0.236</td></tr><tr><td align="center">-1,b9,2,0</td><td align="center">0.367</td><td align="center">0.423</td><td align="center">0.213</td></tr><tr><td align="center">-1,b9,2,1</td><td align="center">0.263</td><td align="center">0.311</td><td align="center">0.223</td></tr><tr><td align="center">-1,b9,2,2</td><td align="center">0.139</td><td align="center">0.170</td><td align="center">0.236</td></tr><tr><td align="center">0,t8,1,0</td><td align="center">0.551</td><td align="center">0.662</td><td align="center">0.009</td></tr><tr><td align="center">0,t8,1,1</td><td align="center">0.468</td><td align="center">0.583</td><td align="center">0.011</td></tr><tr><td align="center">0,t8,1,2</td><td align="center">0.401</td><td align="center">0.516</td><td align="center">0.013</td></tr><tr><td align="center">0,t8,2,0</td><td align="center">0.628</td><td align="center">0.729</td><td align="center">0.007</td></tr><tr><td align="center">0,t8,2,1</td><td align="center">0.543</td><td align="center">0.654</td><td align="center">0.009</td></tr><tr><td align="center">0,t8,2,2</td><td align="center">0.421</td><td align="center">0.537</td><td align="center">0.013</td></tr><tr><td align="center">0,b8,1,0</td><td align="center">0.723</td><td align="center">0.806</td><td align="center">0.006</td></tr><tr><td align="center">0,b8,1,1</td><td align="center">0.652</td><td align="center">0.749</td><td align="center">0.007</td></tr><tr><td align="center">0,b8,1,2</td><td align="center">0.588</td><td align="center">0.694</td><td align="center">0.008</td></tr><tr><td align="center">0,b8,2,0</td><td align="center">0.782</td><td align="center">0.851</td><td align="center">0.005</td></tr><tr><td align="center">0,b8,2,1</td><td align="center">0.716</td><td align="center">0.801</td><td align="center">0.006</td></tr><tr><td align="center">0,b8,2,2</td><td align="center">0.608</td><td align="center">0.712</td><td align="center">0.008</td></tr><tr><td align="center">0,t9,1,0</td><td align="center">0.565</td><td align="center">0.674</td><td align="center">0.009</td></tr><tr><td align="center">0,t9,1,1</td><td align="center">0.482</td><td align="center">0.597</td><td align="center">0.011</td></tr><tr><td align="center">0,t9,1,2</td><td align="center">0.415</td><td align="center">0.530</td><td align="center">0.013</td></tr><tr><td align="center">0,t9,2,0</td><td align="center">0.641</td><td align="center">0.740</td><td align="center">0.007</td></tr><tr><td align="center">0,t9,2,1</td><td align="center">0.557</td><td align="center">0.667</td><td align="center">0.009</td></tr><tr><td align="center">0,t9,2,2</td><td align="center">0.435</td><td align="center">0.551</td><td align="center">0.012</td></tr><tr><td align="center">0,b9,1,0</td><td align="center">0.739</td><td align="center">0.819</td><td align="center">0.006</td></tr><tr><td align="center">0,b9,1,1</td><td align="center">0.670</td><td align="center">0.764</td><td align="center">0.007</td></tr><tr><td align="center">0,b9,1,2</td><td align="center">0.607</td><td align="center">0.711</td><td align="center">0.008</td></tr><tr><td align="center">0,b9,2,0</td><td align="center">0.796</td><td align="center">0.861</td><td align="center">0.005</td></tr><tr><td align="center">0,b9,2,1</td><td align="center">0.733</td><td align="center">0.814</td><td align="center">0.006</td></tr><tr><td align="center">0,b9,2,2</td><td align="center">0.627</td><td align="center">0.728</td><td align="center">0.007</td></tr><tr><td align="center">1,t8,1,0</td><td align="center">0.796</td><td align="center">0.879</td><td align="center">0.001</td></tr><tr><td align="center">1,t8,1,1</td><td align="center">0.742</td><td align="center">0.843</td><td align="center">0.001</td></tr><tr><td align="center">1,t8,1,2</td><td align="center">0.731</td><td align="center">0.835</td><td align="center">0.001</td></tr><tr><td align="center">1,t8,2,0</td><td align="center">0.843</td><td align="center">0.909</td><td align="center">0.001</td></tr><tr><td align="center">1,t8,2,1</td><td align="center">0.795</td><td align="center">0.879</td><td align="center">0.001</td></tr><tr><td align="center">1,t8,2,2</td><td align="center">0.747</td><td align="center">0.846</td><td align="center">0.001</td></tr><tr><td align="center">1,b8,1,0</td><td align="center">0.917</td><td align="center">0.954</td><td align="center">0.001</td></tr><tr><td align="center">1,b8,1,1</td><td align="center">0.891</td><td align="center">0.938</td><td align="center">0.001</td></tr><tr><td align="center">1,b8,1,2</td><td align="center">0.885</td><td align="center">0.935</td><td align="center">0.001</td></tr><tr><td align="center">1,b8,2,0</td><td align="center">0.939</td><td align="center">0.966</td><td align="center">0.001</td></tr><tr><td align="center">1,b8,2,1</td><td align="center">0.917</td><td align="center">0.954</td><td align="center">0.001</td></tr><tr><td align="center">1,b8,2,2</td><td align="center">0.894</td><td align="center">0.940</td><td align="center">0.001</td></tr><tr><td align="center">1,t9,1,0</td><td align="center">0.877</td><td align="center">0.930</td><td align="center">0.001</td></tr><tr><td align="center">1,t9,1,1</td><td align="center">0.840</td><td align="center">0.907</td><td align="center">0.001</td></tr><tr><td align="center">1,t9,1,2</td><td align="center">0.832</td><td align="center">0.902</td><td align="center">0.001</td></tr><tr><td align="center">1,t9,2,0</td><td align="center">0.907</td><td align="center">0.948</td><td align="center">0.001</td></tr><tr><td align="center">1,t9,2,1</td><td align="center">0.876</td><td align="center">0.929</td><td align="center">0.001</td></tr><tr><td align="center">1,t9,2,2</td><td align="center">0.843</td><td align="center">0.909</td><td align="center">0.001</td></tr></tbody></table><br />A couple interesting things I notice:<br /><ul><li>the win probability estimates when trailing by one or when tied are higher with a runner on 1st and no out than with a runner on 2nd and one out. Newsflash: bunting is dumb in general, even when you only need one run.</li><li>some of the PR effects are shockingly large compared to what I had estimated in part 2 for the change in probability of the run scoring. I can only say that I double checked these estimates, and that the estimates from part 2 hadn't allowed for the slowness of the hitter. The other difference I can think of is that (for convenience) my code counted the runner as having scored even if he'd been erased by a fielder's choice and a subsequent runner scored. If this was more common in non-PR situations, it could have led to an understatement of the true PR effect in part 2.<br /></li></ul>In conclusion, I am convinced that pinch running in the late innings is an effective strategy. This was a bit surprising to me, but apparently the small chance of extra innings (and the new, poorer hitter being unable to contribute to a run that the good hitter could have) is outweighed by the relatively large improvement in run scoring in the current inning. The effect seems to get even bigger when the hitter was slow, even if he's a great hitter.<br /><br />I think my next entry will be about late-inning defensive replacements.<br /><br /><br /><span style="font-family:monospace;"><span style="font-weight: bold;">The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com1tag:blogger.com,1999:blog-6005365167182351559.post-39488381582134958932010-07-03T11:08:00.001-04:002010-10-23T07:50:31.903-04:00Are pinch runners effective? Part 2 of 3For the introduction (part 1), see my <a href="http://statisticsinsports.blogspot.com/2010/06/are-pinch-runners-effective-part-1-of-3.html">previous post</a>. In this entry I'm going to estimate the increase in the probability of scoring provided by a pinch runner (PR). My next post (part 3) will attempt to answer the ultimate question: is this increase in probability enough to justify weakening the offense for future innings.<br /><br />After some R coding to count the necessary information, I fit a multiple logistic regression model with:<br /><ul><li>I.run: binary response, the indicator of whether the run scored,</li><li>I.PR: an indicator of whether there was a pinch runner,</li><li>lead: the score difference between the two teams (either -1, 0, or 1). Maybe somewhat surprisingly this makes a difference,<br /></li><li>outs: the number of outs when the runner first got on base (this is categorical because there's no reason outs would be related linearly to the log odds of scoring),</li><li>I.2nd: an indicator of whether the runner was on 2nd base (the alternative is the reference level, 1st base),</li><li>player: identity of the original runner (for parsimony I'm lumping all pinch runners together as being fast guys),</li></ul>while limiting the data as described in the introduction.<br /><br />I'm making the assumption that there are only three outcomes stemming from possibly pinch running: the run won't score either way, it will score either way, or the PR would score when the original player would've been stranded. I'm ignoring the possible effects - that is, on subsequent runs in this inning that are less likely because of the extra out - of the slow runner being more susceptible to getting thrown out on the bases (by a force play or otherwise). I imagine the frequency of being thrown out when the PR wouldn't have been is low compared to the frequency of times this slow runner just gets held up by the 3rd base coach when the PR wouldn't have been. Regardless, it might get too complicated figuring out how much this extra out affects the distribution of run scoring in the inning. However if I fail to find that pinch running is beneficial (in part 3), I may have to revisit this assumption. I can think of two different ways to weaken it:<br /><ul><li>instead of the binary response, the response could be a count of the number of runs scored in the inning subsequent to this runner reaching base. I balked at that for this entry because in an entry last year, I had trouble getting R to do multinomial regression with covariance matrices provided - but that data set was bigger, so it may be worth a shot in my next post,</li><li>instead of separating steps 1 and 2, just fit a binary logistic regression with win/loss as the response. This gets at the question directly, but I'm worried that the response will be pretty noisy.</li></ul>I considered the past 15 seasons (1995-2009), where a total of 720 different players satisfied the following two conditions: (i) they were both pinch run for and allowed to run for themselves in the 8th inning or later of a tie or one-run game, and (ii) they scored or had their PR score. The second condition removes about half a percent of the population left after the first condition, and I think it creates a minor selection bias - non-PR situations are being deleted more than PR situations (because there are many more non-PR situations), and the proportion of deletions corresponding to successes is probably not exactly the same as the proportion left in the sample. But without the second condition it would be impossible to estimate a player effect, so I required it anyway.<br /><br />There are a number of interactions that could potentially enter the logistic model, but only two interactions were close to significant (for more on the I.PR:player interaction see the end of this post); they are shown below. I used the default treatment contrasts in R for I.PR, lead, outs, and I.2nd, but sum contrasts for the players, so the intercept corresponds to the log odds of scoring for the average player, running for himself, after a lead-off single when trailing by one run. The parameter estimates and their p-values are listed below; the residual deviance is 32836 on 27742 degrees of freedom, making the overdispersion parameter estimate less than 1.09, so I didn't bother allowing for overdispersion. It would not have changed any of the conclusions anyway. I've included David Ortiz's estimate below because he will come up again in a moment.<br /><table align="center"><tbody><tr><td align="center"> intercept </td><td align="center"> -0.430 </td><td align="center"> 2e-16 *** </td></tr><tr><td align="center"> I.PR </td><td align="center"> 0.086 </td><td align="center"> 0.161</td></tr><tr><td align="center"> lead0<br /></td><td align="center"> 0.104 </td><td align="center"> 0.004 ** </td></tr><tr><td align="center"> lead1<br /></td><td align="center"> 0.216 </td><td align="center"> 2.48e-07 *** </td></tr><tr><td align="center"> outs1 </td><td align="center"> -0.661 </td><td align="center"> 2e-16 *** </td></tr><tr><td align="center"> outs2 </td><td align="center"> -1.476 </td><td align="center"> 2e-16 *** </td></tr><tr><td align="center"> I.2nd </td><td align="center"> 0.774 </td><td align="center"> 2e-16 *** </td></tr><tr><td align="center"> outs1:I.2nd </td><td align="center"> -0.207 </td><td align="center"> 0.011 * </td></tr><tr><td align="center"> outs2:I.2nd </td><td align="center"> -0.305 </td><td align="center"> 0.002 ** </td></tr><tr><td align="center"> I.PR:lead0<br /></td><td align="center"> 0.161 </td><td align="center"> 0.046 * </td></tr><tr><td align="center"> I.PR:lead1<br /></td><td align="center"> 0.146<br /></td><td align="center"> 0.209 </td></tr><tr><td align="center"> Ortiz </td><td align="center"> 0.674<br /></td><td align="center"> 0.010 * </td></tr></tbody></table><br />The coefficient estimates of interest are the ones concerning I.PR. The main effect for I.PR says that exp(0.086) is the multiplicative change in the odds of scoring created by pinch running when lead=-1, and similarly adding the main effect to each interaction term allows estimation of the multiplicative change in the odds when lead=0 or 1. I expect the more meaningful number in part 3 will be the additive change in probability - this will be different depending on the situation. The following table compares the probability of scoring a run with no PR to the probability of scoring a run with a PR in all 18 situations. This is done for an average player. A Taylor series expansion was used to estimate the variance of the difference of the probability estimates, and normality was assumed to calculate the p-values for the one-sided tests of those differences.<br /><table align="center" border="1"><tbody><tr><th align="center">situation</th> <th align="center"> P(run) no PR </th><th align="center"> P(run) PR </th> <th align="center"> p-value </th></tr><tr><td align="center">lead=-1,base=1,outs=0</td><td align="center">0.394</td><td align="center">0.415</td><td align="center">0.081</td></tr><tr><td align="center">lead=-1,base=1,outs=1</td><td align="center">0.251</td><td align="center">0.268</td><td align="center">0.082</td></tr><tr><td align="center">lead=-1,base=1,outs=2</td><td align="center">0.129</td><td align="center">0.139</td><td align="center">0.084</td></tr><tr><td align="center">lead=-1,base=2,outs=0</td><td align="center">0.585</td><td align="center">0.606</td><td align="center">0.080</td></tr><tr><td align="center">lead=-1,base=2,outs=1</td><td align="center">0.372</td><td align="center">0.392</td><td align="center">0.082</td></tr><tr><td align="center">lead=-1,base=2,outs=2</td><td align="center">0.192</td><td align="center">0.206</td><td align="center">0.084</td></tr><tr><td align="center">lead=0,base=1,outs=0</td><td align="center">0.419</td><td align="center">0.480</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=1,outs=1</td><td align="center">0.271</td><td align="center">0.323</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=1,outs=2</td><td align="center">0.142</td><td align="center">0.174</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=2,outs=0</td><td align="center">0.610</td><td align="center">0.667</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=2,outs=1</td><td align="center">0.396</td><td align="center">0.457</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=2,outs=2</td><td align="center">0.209</td><td align="center">0.252</td><td align="center">0.000</td></tr><tr><td align="center">lead=1,base=1,outs=0</td><td align="center">0.447</td><td align="center">0.504</td><td align="center">0.011</td></tr><tr><td align="center">lead=1,base=1,outs=1</td><td align="center">0.294</td><td align="center">0.344</td><td align="center">0.013</td></tr><tr><td align="center">lead=1,base=1,outs=2</td><td align="center">0.156</td><td align="center">0.189</td><td align="center">0.016</td></tr><tr><td align="center">lead=1,base=2,outs=0</td><td align="center">0.636</td><td align="center">0.688</td><td align="center">0.009</td></tr><tr><td align="center">lead=1,base=2,outs=1</td><td align="center">0.423</td><td align="center">0.481</td><td align="center">0.012</td></tr><tr><td align="center">lead=1,base=2,outs=2</td><td align="center">0.228</td><td align="center">0.271</td><td align="center">0.015</td></tr></tbody></table><br />The following table is the same as the previous one, except it's for David Ortiz instead of the average player. He often hit prior to Manny Ramirez or Kevin Youkilis (good hitters).<br /><table align="center" border="1"><tbody><tr><th align="center">situation</th> <th align="center"> P(run) no PR </th><th align="center"> P(run) PR </th> <th align="center"> p-value </th></tr><tr><td align="center">lead=-1,base=1,outs=0</td><td align="center">0.561</td><td align="center">0.582</td><td align="center">0.080</td></tr><tr><td align="center">lead=-1,base=1,outs=1</td><td align="center">0.397</td><td align="center">0.418</td><td align="center">0.082</td></tr><tr><td align="center">lead=-1,base=1,outs=2</td><td align="center">0.226</td><td align="center">0.241</td><td align="center">0.086</td></tr><tr><td align="center">lead=-1,base=2,outs=0</td><td align="center">0.735</td><td align="center">0.751</td><td align="center">0.082</td></tr><tr><td align="center">lead=-1,base=2,outs=1</td><td align="center">0.537</td><td align="center">0.559</td><td align="center">0.080</td></tr><tr><td align="center">lead=-1,base=2,outs=2</td><td align="center">0.318</td><td align="center">0.337</td><td align="center">0.083</td></tr><tr><td align="center">lead=0,base=1,outs=0</td><td align="center">0.586</td><td align="center">0.644</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=1,outs=1</td><td align="center">0.422</td><td align="center">0.483</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=1,outs=2</td><td align="center">0.244</td><td align="center">0.293</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=2,outs=0</td><td align="center">0.754</td><td align="center">0.797</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=2,outs=1</td><td align="center">0.563</td><td align="center">0.623</td><td align="center">0.000</td></tr><tr><td align="center">lead=0,base=2,outs=2</td><td align="center">0.341</td><td align="center">0.398</td><td align="center">0.000</td></tr><tr><td align="center">lead=1,base=1,outs=0</td><td align="center">0.613</td><td align="center">0.666</td><td align="center">0.010</td></tr><tr><td align="center">lead=1,base=1,outs=1</td><td align="center">0.450</td><td align="center">0.507</td><td align="center">0.011</td></tr><tr><td align="center">lead=1,base=1,outs=2</td><td align="center">0.266</td><td align="center">0.313</td><td align="center">0.016</td></tr><tr><td align="center">lead=1,base=2,outs=0</td><td align="center">0.774</td><td align="center">0.812</td><td align="center">0.012</td></tr><tr><td align="center">lead=1,base=2,outs=1</td><td align="center">0.590</td><td align="center">0.645</td><td align="center">0.010</td></tr><tr><td align="center">lead=1,base=2,outs=2</td><td align="center">0.366</td><td align="center">0.422</td><td align="center">0.013</td></tr></tbody></table><br />The Ortiz coefficient's standard error was 0.263, so these probability estimates may be larger than the true probabilities: and surely they are because even Manny Ramirez cannot hit about .400, which is what the two-out numbers above are suggesting, with RISP in the long term.<br /><br />We can see from the low p-values in both tables that pinch running helps increase the chance of scoring, at least when the leading or tied. The PR effect is actually much bigger than I imagined it would be. Other than the large probability increases from the 1st table to the 2nd, there are a couple of interesting things. First, as the I.PR*lead interaction suggested, the PR effect is much smaller when the team is trailing; the raw probability of scoring is also smaller when trailing. I think the latter is easily explained by the fact that the opposing team's best pitchers tend to be their set-up man and closer, and these are the pitchers you face when trailing by one run in the 8th or 9th inning. Another less likely explanation might be that if you are losing by one run, you are not hitting as well on the day, and hence less likely to score. This gets into the "hot hand effect" though, and so I think the likely explanation is the opposing pitching.<br /><br />I don't think the smaller PR effect in games where the team is trailing is as intuitive, but it probably also has a lot to do with facing the opposing team's best pitching: the speed of your base runner is not important if the subsequent hitters are not getting hits. I actually fit a poisson regression with expected runs scored subsequent to the runner reaching base as the response, and interestingly the expected runs scored with the PR when trailing by one were <span style="font-style: italic;">lower</span> than the expected runs with no PR. The effect was extremely small and not statistically significant, but with the size of my sample I wouldn't expect to see that. I wonder if it has to do with a different strategy being employed when trailing - the PR tries to steal 2nd base, or the manager tries to bunt him over to 2nd base. Either of these moves certainly decrease the expected runs scored in the inning (although possibly increasing the chance of scoring at least one run).<br /><br />By not allowing for an interaction between I.PR and player, which would measure how fast the original base runner is, I've basically assumed that David Ortiz has the same speed as the average player (at least, average among those who have ever pinch run for - which is almost everybody at one time or another). But the variation in each of these interaction estimates would be even bigger than the variation we're now seeing in the player estimates, so I didn't bother with this here; I will have to include this is my final analysis in part 3 though, perhaps averaging several players together to more precisely estimate an overall effect of pinch running for good hitters. Anyway, because Ortiz is unusually slow, you can probably safely take away a little bit from Ortiz's probabilities and add a little bit to his PR's.<br /><br />This wraps up step 1. I've had to make some simplifications and assumptions to fit this logistic model (some of which I might have to try to relax in my next post), but at least the data have allowed me to show that pinch running significantly increases the chance of scoring.<br /><br /><br /><span style="font-family:monospace;"><span style="font-weight: bold;">The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-72937234014507123552010-06-29T23:24:00.001-04:002010-10-23T07:49:44.854-04:00Are pinch runners effective? Part 1 of 3Late in a close game when a slow runner gets on base, a manager will often remove him in favour of a pinch runner (PR), hoping to score a vital run. This can be done when the team is ahead and trying to get an insurance run, when the team is tied and trying to take the lead, or when the team is behind and trying to tie the game. I'm skeptical of this strategy because although the chances of scoring in the current inning are no doubt increased, this spot in the batting order may well come up again later, and the superior hitter who used to occupy it will no longer be in the game. Here's a cursory discussion that says it may work though: <a href="http://www.tangotiger.net/wiki/index.php?title=Mailbags#Pinch_runners_-_how_much_value_do_they_have.3F">Tango analysis</a>.<br /><br />The optimal strategy will likely depend on a few things:<br /><ul><li>how many outs there are - perhaps with two outs, it won't be worthwhile to use a PR because the runner, regardless of his speed, is so unlikely to score, but with no outs it will be worth it,</li><li>whether the runner is on 1st base or 2nd base (pinch running tends not to happen at 3rd base),</li><li>the run difference between the two teams,</li><li>the inning,</li><li>the hitting ability of the player who reached base, and the hitting ability of the other players in his team's lineup as well as the other team's lineup.</li></ul>I've decided to break the problem into two steps, which will be the subject of my upcoming entries. This post will just serve as the introduction. The first step will be to estimate how much more likely the run is to score when the PR enters the game. The second step, which will be more complicated, will address the runs that are lost in future innings due to the decrease in the lineup's hitting ability. It's not yet clear to me what exactly must be estimated in step 2 in order to solve the overarching question. It will involve the probability of this spot in the order coming to bat again, which will of course depend on the current inning and score, and the estimation in this step may have to happen jointly with step 1 in order to get a sensible variance estimate.<br /><br />To deal with step 1, I don't want to just blindly compare pinch running situations to situations with no PR - the lack of PR may indicate that the player who reached base is fast himself, and this will mitigate any true PR effect. I want to limit the sample to players who are sometimes pinch run for and sometimes not, and then control for player (and hence implicitly his team) in the model.<br /><br />I'm going to limit the data to close games (within one run) in the late innings (8th or later). A gross PR effect (step 1) could be estimated without these restrictions (although pinch running in other situations may have more to do with resting a player or replacing an injured player), but the net effect that needs to be estimated in step 2 involves the manager's strategic decision to remove the man on base, believing either that this spot in the order is unlikely to reach the plate again, or that the immediacy of the potentially ensuing run takes precedence. I also want to limit the situations to PRs (or no PRs) when only one man is on base; this will keep the number of possible situations low - either there is a runner on 1st and nowhere else, or there is a runner on 2nd and nowhere else.<br /><br />One other thing to note is that I'm not dealing with pitchers here. Deciding whether to pinch run for the pitcher is a completely different scenario, although it probably doesn't happen that much anyway because he'd sooner be pinch hit for.<br /><br />Fortunately having <a href="http://statisticsinsports.blogspot.com/2009/10/score-of-game-and-pitcher-performance.html">previously</a> dealt with the Retrosheet play-by-play data needed to set up the model, the parsing of data shouldn't be too time consuming.<br /><br />Stay tuned for part 2!David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-47892774519635046662009-11-06T19:02:00.001-05:002010-10-23T07:47:59.551-04:00Closers in non-save situationsClosers in baseball today are specialists who get psyched up to come to the mound in the 9th inning and protect a small lead. The top performers are quite effective at this, but I've often heard the pundits and fellow fantasy baseball enthusiasts complain that managers bring the closers into non-save situations and screw up their ratios (ERA and WHIP). The theory is that when the team is already up by a few runs, or is losing, the closer can't have the same intensity. I've always been a bit skeptical about this; it sounds a lot like the clutch hitting myth, so today I'm going to investigate.<br /><br />I've seen a couple articles (<a href="http://www.hardballtimes.com/main/article/does-trevor-hoffman-struggle-in-non-save-situations/">here</a> and <a href="http://bleacherreport.com/articles/43994-whats-the-deal-with-mariano-riveras-non-save-struggles">here</a>) that have approached this problem in an heuristic way and only for one closer. I picked the first 6 closers off the top of my head - Trevor Hoffman, Bobby Jenks, Joe Nathan, Jonathan Papelbon, Mariano Rivera, and Billy Wagner - and I'll do some inference to see if any of them pitch significantly better when in save situations. I've limited the analyses to seasons when they were full-time closers.<br /><br />The incredible <a href="http://www.baseball-reference.com/">Baseball-Reference</a> has split stats for every pitcher for every year, and this includes all major performance indicators in save situations and in non-save situations, so getting the data into the right format was easy. The following graphs show the <a href="http://en.wikipedia.org/wiki/Defense_independent_pitching_statistics">FIP</a> and ERA for the 6 closers with the red indicating save situations and the blue indicating non-save situations. I threw out a partial season for both Hoffman and Wagner (mostly to make the graphs look nicer).<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_ZO7aBfXMj_E/TMLLBHon9BI/AAAAAAAAAAg/I4BgpgAoRGk/s1600/hoffman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="319" src="http://1.bp.blogspot.com/_ZO7aBfXMj_E/TMLLBHon9BI/AAAAAAAAAAg/I4BgpgAoRGk/s320/hoffman.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_ZO7aBfXMj_E/TMLLDYK037I/AAAAAAAAAAk/vgUzaAzCSBQ/s1600/jenks.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="319" src="http://1.bp.blogspot.com/_ZO7aBfXMj_E/TMLLDYK037I/AAAAAAAAAAk/vgUzaAzCSBQ/s320/jenks.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_ZO7aBfXMj_E/TMLLHT9OHpI/AAAAAAAAAAo/-m2cu6qK9s0/s1600/nathan.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="319" src="http://1.bp.blogspot.com/_ZO7aBfXMj_E/TMLLHT9OHpI/AAAAAAAAAAo/-m2cu6qK9s0/s320/nathan.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"> <a href="http://2.bp.blogspot.com/_ZO7aBfXMj_E/TMLLJvOu5HI/AAAAAAAAAAs/CSd6GL_BHUw/s1600/papelbon.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="319" src="http://2.bp.blogspot.com/_ZO7aBfXMj_E/TMLLJvOu5HI/AAAAAAAAAAs/CSd6GL_BHUw/s320/papelbon.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_ZO7aBfXMj_E/TMLLKodXZvI/AAAAAAAAAAw/oEOYVql5YOI/s1600/rivera.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="319" src="http://1.bp.blogspot.com/_ZO7aBfXMj_E/TMLLKodXZvI/AAAAAAAAAAw/oEOYVql5YOI/s320/rivera.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_ZO7aBfXMj_E/TMLLL1xhyXI/AAAAAAAAAA0/KwdVKXnaI4M/s1600/wagner.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="319" src="http://3.bp.blogspot.com/_ZO7aBfXMj_E/TMLLL1xhyXI/AAAAAAAAAA0/KwdVKXnaI4M/s320/wagner.png" width="320" /></a></div>I thought if there was a difference in performance between the two situations that there could be a time trend - perhaps the veteran closer has learned how to perform in the non-save situations better than the raw, young closer. But these graphs show no obvious interaction between time and situation for any closer, so to perform my statistical analyses I aggregated the stats across all years.<br /><br />For each player/situation combination I got estimates for the probability of a home run (HR), walk or hit by pitch (BB), strikeout (K), and of another type of out (out). Dividing the numerator and denominator of the usual FIP formula by PA, we see that FIP = 3(13P(HR) + 3P(BB) - 2P(K))/(P(K)+P(out)) + 3.2. And since it's written as a function of the probabilities and we know the covariance of <a href="http://en.wikipedia.org/wiki/Multinomial_distribution">multinomial probabilities</a>, the delta method can be applied to get the variance of each FIP estimate.<br /><br />The following table shows the FIP estimates for save situation and non-save situation, and the p-value - assuming normality of the estimates - for the test of FIP(SV) less than FIP(NSV).<br /><br /><table align="center" border="1"><tbody><tr><th align="center">Pitcher </th><th align="center">FIP(SV) </th><th align="center">FIP(NSV) </th><th align="center">p-value </th></tr><tr><td align="center">Hoffman </td><td align="center">2.83 </td><td align="center">3.30 </td><td align="center">0.08 </td></tr><tr><td align="center">Jenks </td><td align="center">3.31 </td><td align="center">3.57 </td><td align="center">0.33 </td></tr><tr><td align="center">Nathan </td><td align="center">2.67 </td><td align="center">2.14 </td><td align="center">0.90 </td></tr><tr><td align="center">Papelbon </td><td align="center">2.51 </td><td align="center">2.34 </td><td align="center">0.63 </td></tr><tr><td align="center">Rivera </td><td align="center">2.71 </td><td align="center">3.06 </td><td align="center">0.12 </td></tr><tr><td align="center">Wagner </td><td align="center">2.75 </td><td align="center">2.63 </td><td align="center">0.64 </td></tr></tbody></table><br />We can see that three pitchers actually pitch better in non-save situations and even without controlling for multiple testing, no pitcher is significantly better in save situations. That doesn't mean that this will hold for every closer (although I suspect all significant differences would be false positives), but for these 6 the myth has been broken!<br /><br />The data used here were obtained from <a href="http://www.baseball-reference.com/">Baseball-Reference</a>.David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-4470623499635158662009-10-18T11:52:00.001-04:002010-10-23T07:44:36.870-04:00Score of the game and pitcher performanceContinuing my <a href="http://statisticsinsports.blogspot.com/2009/09/does-one-long-half-inning-lead-to.html">previous post</a>, I will now briefly analyze the association between the score the game and some pitching stats. I certainly expected to see some statistical significance here as I used more data - a pitcher with a big lead will probably throw more strikes, giving up more home runs and fewer walks, to limit the probability of a big inning. I was interested in seeing just how big this effect is. Perhaps the FIP for pitchers with a big lead is actually lower than for those with a smaller lead, and pitchers should consider throwing more strikes all the time? Anyway, I'm sure a more detailed study on this, and the associated win probabilities for different pitching strategies has already been done.<br /><br />I fit binomial logistic models (one each for HR, BB, and K) accounting for team at bat and for the pitcher (and number of pitches in the previous inning). The other factor was either lead^2 or just lead of the team pitching. With lead^2, I got coefficients and p-values:<br /><table align="center"><tbody><tr><td align="center"> HR </td><td align="center"> 0.0032 </td><td align="center"> 8.53e-05 *** </td></tr><tr><td align="center"> BB </td><td align="center"> -0.0027 </td><td align="center"> 1.14e-05 *** </td></tr><tr><td align="center"> K </td><td align="center"> -0.0011 </td><td align="center"> 0.017213 * </td></tr></tbody></table><br />Lead^2 is significant for HR, BB, and K, but each translates to less than half a percent multiplicative change in the odds of the associated counting statistic for each increase of one in lead^2. There are indeed more HR and fewer BB (and fewer K) when the game is not close, but for every 200 HR you see with lead^2 = x, you'll see less than one extra HR for lead^2 = x+1. This works out to about 10% more home runs in 5 run games than in tie games.<br /><br />I fit the same model with lead instead of lead^2, and the effects were in the same direction but not as large, and the lead effect in the K model was not significant at all. This implies that pitchers on both sides throw more strikes when the game isn't close.<br /><br /><br /><span style="font-family:monospace;"><span style="font-weight: bold;">The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-1493207703301639712009-09-02T08:47:00.001-04:002010-10-23T07:43:47.044-04:00Does one long half inning lead to another?I've sometimes heard announcers say that while a pitcher loves watching his team rally, he gets tight sitting on the bench for so long, and his performance in the next half inning may suffer. This mildly relates to my <a href="http://statisticsinsports.blogspot.com/2009/08/yankees-icing-opposing-pitchers.html">previous post</a> about a long 7th inning stretch not affecting the pitcher. But a long rally could mean 15, 20, even 25 minutes on the bench for a pitcher, so maybe that's enough time for his performance in the next half inning to suffer?<br /><br />My idea to answer this question was to fit a multinomial logistic regression with the levels of the response being the necessary counts to estimate FIP: HR, BB+HBP, K, other outs; and the predictors being team at bat, pitcher, stadium, and pitches in the previous inning. The data from Retrosheet doesn't have the time of each half inning, but I figure pitches thrown is going to be highly correlated with actual time, and will suffice. Once the parameters in the multinomial logistic regression are estimated, one could easily estimate FIP=(13HR+3(BB+HBP)-2K)/IP for different values of pitches in the previous inning (for the average pitcher and average team at bat) and use the multivariate delta method to find the variance of each FIP estimate.<br /><br />I didn't want to use linear regression with FIP as the response because it would basically be categorical. Moreover, sometimes IP=0, so I couldn't model FIP directly anyway - limiting the interpretability of my results for those who want to see FIP, and not some transformation of it.<br /><br />I think the multinomial regression is necessary rather than a few binomial regressions because to estimate the variance of the FIP estimates, we need to take into account the covariance in the parameter estimates (any glm fit in R will spit out a correlation matrix of parameter estimates upon request). If using only binomial regressions, we can't estimate the correlation between the coefficient for pitches in the previous inning in the HR/PA model and the corresponding coefficient in the BB/PA model, for example.<br /><br />Unfortunately, the multinomial regression functions available in R don't seem up to the task. (Let me know if I'm missing something.) But vglm in the VGAM package wants the data in binary form, which makes the already large data set (with one row for each inning) even larger, requiring a separate row for each PA. R then runs out of memory when finding the root - at least when I'm using all the PA from 2007-2008. The other function I found, multinom in the nnet library, doesn't seem to compute the covariance matrix.<br /><br />But to answer today's question, it turns out one doesn't really need to look at the FIP. After some painful character string manipulation to parse the data, I fit three separate binomial logistic regressions - for HR, BB, K - and in none of them is the coefficient for previous pitches even close to significant, nor are any of the estimates practically different from zero. Below are the coefficients and the corresponding p-values:<br /><table align="center"><tbody><tr><td align="center">HR </td><td align="center">-0.0026 </td><td align="center">0.14 </td></tr><tr><td align="center">BB </td><td align="center">0.0012 </td><td align="center">0.26 </td></tr><tr><td align="center">K </td><td align="center">-0.0003 </td><td align="center">0.70 </td></tr></tbody></table><br />So it looks like length of the previous inning does not have any effect on the pitcher, and he should be wholeheartedly cheering for his team to score runs - even if he's mostly interested in his own sabermetric stats.<br /><br />Next time, I'll use similar code to analyze the relationship between the score of the game and HR, BB, K allowed. It looks like there are some significant differences there.<br /><br /><span style="font-family: monospace;"><span style="font-weight: bold;">The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-44786736140496910242009-08-13T20:49:00.002-04:002010-10-23T07:41:21.182-04:00Fielding Independent PitchingI was working on a longer post about how a pitcher's performance might be affected by the score of the game, or how long the previous half inning took, and I realized that the <a href="http://en.wikipedia.org/wiki/Defense_Independent_Pitching_Statistics">FIP</a> formula developed by Tom Tango was a bit counter-intuitive to me. I know there are more complex formulas that can perform better, but as a quick predictor of future ERA, FIP seems to be the popular choice. What puzzled me was the use of IP rather than plate appearances (PA) - I thought using IP would bring luck back into the equation, and hence predict lower ERAs for pitchers who happened to have a low <a href="http://en.wikipedia.org/wiki/BABIP">BABIP</a> in the preceding season.<br /><br />So I did some quick analyses using data from 1995-2008. I fit a weighted (based on IP) multiple linear regression model with season ERA as the response and the previous season's HR/IP, (BB+HBP)/IP, and K/IP as predictors. I limited the analysis to pitchers who had pitched at least 130 innings in both the predictor year and the response year. I'm sure the results wouldn't change much if I didn't use the innings quota, but I wanted to focus on starting pitchers because that's the group my next post will be about. The multiple regression assumptions of homoscedasticity and linearity appear to be reasonable:<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_ZO7aBfXMj_E/TMLIRSToaOI/AAAAAAAAAAU/5u2qE2T6WOo/s1600/fip+resids.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="319" src="http://2.bp.blogspot.com/_ZO7aBfXMj_E/TMLIRSToaOI/AAAAAAAAAAU/5u2qE2T6WOo/s320/fip+resids.jpeg" width="320" /></a></div>The estimates (all highly significant) are:<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_ZO7aBfXMj_E/TMLJE_zhQuI/AAAAAAAAAAY/SYLUH2BygX0/s1600/ip.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/_ZO7aBfXMj_E/TMLJE_zhQuI/AAAAAAAAAAY/SYLUH2BygX0/s1600/ip.jpg" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"></div><br />Rounding off to the nearest integer, my formula agrees with FIP. Then I fit the same model, but with HR/PA, (BB+HBP)/PA, and K/PA (using PA as the weight), and got:<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_ZO7aBfXMj_E/TMLJP33ivfI/AAAAAAAAAAc/seW956hS_Ws/s1600/pa.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/_ZO7aBfXMj_E/TMLJP33ivfI/AAAAAAAAAAc/seW956hS_Ws/s1600/pa.jpg" /></a></div><br />The higher R^2 for the innings pitched model tells us that model does a better job of predicting ERA for the subsequent season. Removing balls in play from the regression equation reduced the quality of the fit, so this is evidence that pitchers do have some control over BABIP.<br /><br /><br /><span style="font-family: monospace;"><span style="font-weight: bold;">The data used here were obtained from <a href="http://www.fangraphs.com/">FanGraphs</a>.</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-82397632512928124992009-08-02T10:11:00.004-04:002010-10-23T07:58:27.561-04:00Yankees icing opposing pitchers?Ever since September 11, 2001, "God Bless America" has been played at the 7th inning stretch of all games at Yankee Stadium, slightly delaying the start of the bottom of the 7th. Other stadiums reserve playing the song for special occasions such as Opening Day, Memorial Day, the 4th of July, and 9/11.<br /><br />I've often read that this extended break before the bottom of the 7th "ices" the opposing pitcher, much like a timeout before a field goal attempt supposedly distresses a placekicker. This break gets even longer during the postseason when they trot out Dr. Ronan Tynan to sing an extended live version, making the visiting pitcher - and everyone else - stand still (<a href="http://www.nbcnewyork.com/news/sports/You-Can-Now-Honor-America-From-The-Yankee-Stadium-Loo.html">they used to really frown on movement during the song!</a>) while Dr. Tynan sings. I would think this delay might affect a new pitcher coming in from the bullpen more than it would affect the old one coming from the dugout - because the guy in the dugout already sat still for the top of the 7th inning. But either way, the claim is that the Yankees seem to do quite well in the bottom of the 7th at home, <a href="http://www.nytimes.com/2003/10/04/sports/sports-of-the-times-yankees-seventh-inning-stretch-shouldn-t-be-so-stretched-out.html">especially in the playoffs</a>, since 9/11/2001.<br /><br />I've seen a couple analyses confirming this effect (I won't name names) that don't really seem to get at the issue. I think the way to simply test for a "God Bless America" effect is to take into account the dynamic annual strength of the Yankee offense, and to limit the analysis to Yankee Stadium games in order to control for park effect. A more complicated analysis could of course take into account opposing pitching strength, injuries, etc.<br /><br />Rather than looking directly at runs, it would be preferable to look at a sabermetric statistic like <a href="http://en.wikipedia.org/wiki/Base_Runs">base runs</a>, but I'm going to be lazy and look at runs directly. The number of runs the Yankees score in the bottom of the 7th inning of a given game is a count, so it's natural to model it with the Poisson distribution, incorporating an offset for the strength of the Yankee offense. I'll estimate the strength of the offense as the number of runs they score during the whole regular season at home; this actually has a bigger range than I thought, going from 520 runs in 2007 to just 412 runs in 2008 - no doubt partly due to A-Rod's injury. I'll start by considering just the regular season games played between 1995 and 2008. The required quasi-Poisson regression model is:<br /><br /><table align="center"><tbody><tr><td align="center">log(E(runs)) = log(strength) + <span style="font-style: italic;">b</span>*GBA,</td></tr></tbody></table><br />where E(runs) denotes the expected value (or mean) of 7th inning runs, and GBA is 1 if the game took place after 9/11/2001, and 0 if before. The results (from <a href="http://cran.r-project.org/">R</a>) for <span style="font-style: italic;">b</span> are:<br /><table align="center"><tbody><tr><td align="center">Estimate </td><td align="center">p-value </td></tr><tr><td align="center">-0.002675 </td><td align="center">0.98 </td></tr></tbody></table><br />(Dispersion parameter for quasipoisson family taken to be 2.29)<br /><br />The Yanks are actually scoring at a slightly higher rate in the bottom of the 7th since 9/11/2001 (not shown), but the results above show that after controlling for their increasing offensive strength, they are scoring at a lower rate since the addition of the song! The rate change is highly insignificant though, with a p-value of 0.98. But the mumbling about an unfair advantage appears to be unfounded. What about a playoff advantage though? That's what the opposition really gripes about... it turns out no complicated modeling is necessary to answer that question.<br /><br />Between 1995 and 2000, the Yanks played 31 home playoff games, and scored 29 7th inning runs, for an average of 0.94. They scored at least once in the 7th 14 times. Between 2001 and 2008, the Yanks played 32 home playoff games, and scored 15 7th inning runs, for an average of 0.47. In those years they scored at least once in the 7th only 9 times!<span style="text-decoration: underline;"> </span><br /><span style="text-decoration: underline;"></span><br /><span style="text-decoration: underline;"></span><br /><span style="text-decoration: underline;"></span><br /><span style="text-decoration: underline;"></span><br /><span style="text-decoration: underline;"></span><br /><span style="text-decoration: underline;"></span><br /><span style="text-decoration: underline;"></span><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_ZO7aBfXMj_E/TMLHYk29i_I/AAAAAAAAAAQ/c7SVppVHNds/s1600/yanks+in+7th.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="319" src="http://4.bp.blogspot.com/_ZO7aBfXMj_E/TMLHYk29i_I/AAAAAAAAAAQ/c7SVppVHNds/s320/yanks+in+7th.png" width="320" /></a></div><span style="text-decoration: underline;"> </span>So it turns out that Dr. Tynan's long performance of "God Bless America" doesn't really throw the opposing pitchers off their game any more than being late in the game in the playoffs at Yankee Stadium has already done. If anything, it seems like it might help the opposition... of course the sample size is pretty small.<br /><br />Or... maybe the live song has helped the Yanks, but A-Rod has single-handedly mitigated the benefits! :)<br /><br /><span style="font-family: monospace;"><span style="font-weight: bold;"><br />The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".</span></span>David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0tag:blogger.com,1999:blog-6005365167182351559.post-35542094093675899642009-07-31T23:56:00.000-04:002010-10-19T17:46:08.206-04:00WelcomeThis is the first of possibly many blog entries about statistics in baseball. A bit about me: I'm a Ph.D. student in Statistics at Cornell University, and I've been a baseball fan since I was about five years old I suppose. I started playing fantasy baseball in the early 90's, and I've been at it ever since.<br /><br />I'm not sure how often I'll have time to write, or how accessible all of my writings will be to the casual statistician, but I hope some people will read what I write here, and maybe I'll actually be filling a niche: baseball analysis with more rigorous statistics than most blogs. It'll be good practice for my own data analysis skills too - something I don't get much of.<br /><br />I've recently downloaded some data from www.retrosheet.org, and I'm required to cite them with the following statement whenever I use the data: The information used here was obtained free of charge from and is copyrighted by Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org". This incredibly useful site has free downloads of the play by play information and summary information for the vast majority of MLB games ever played, and complete data for everything recent.<br /><br />I'll use the statistical package <a href="http://cran.r-project.org/">R</a> for my data analysis. The first question I'll tackle is whether the Yankees' "icing" of opposing pitchers with their long 7th inning stretch is actually effective. Stay tuned.David Clementhttp://www.blogger.com/profile/14903688130603212290noreply@blogger.com0