<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Temporal Disruption &#187; Baseball</title>
	<atom:link href="http://www.temporaldisruption.com/category/baseball/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.temporaldisruption.com</link>
	<description></description>
	<lastBuildDate>Thu, 22 Jul 2010 04:28:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Come On Reyes, Cruise For Me</title>
		<link>http://www.temporaldisruption.com/2010/04/10/come-on-reyes-cruise-for-me/</link>
		<comments>http://www.temporaldisruption.com/2010/04/10/come-on-reyes-cruise-for-me/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 16:34:07 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[Ben Zobrist]]></category>
		<category><![CDATA[Derek Jeter]]></category>
		<category><![CDATA[fantasy baseball]]></category>
		<category><![CDATA[Jose Reyes]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=632</guid>
		<description><![CDATA[Come on (Reyes') knees, don't be mean.]]></description>
			<content:encoded><![CDATA[<p>Much of my fantasy baseball strategy this year revolved around drafting <a href="http://www.fangraphs.com/statss.aspx?playerid=1736&#038;position=SS">Jose Reyes</a> in the 3rd or 4th round.  Admittedly, part of my plan involved taking <a href="http://www.fangraphs.com/statss.aspx?playerid=7435&#038;position=2B/SS/OF">Zobrist</a> or <a href="http://www.fangraphs.com/statss.aspx?playerid=826&#038;position=SS">Jeter</a> in the 4th should Reyes not fall to me.  Needless to say, I was able to get Reyes in the 4th.  With his first start being this afternoon, and all reports from extended spring training and minor league starts being positive, I am optimistic that today is the beginning of the end for my fantasy opponents.</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/2_5edxArGT8&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/2_5edxArGT8&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>Come on (Reyes&#8217;) knees, don&#8217;t be mean.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2010/04/10/come-on-reyes-cruise-for-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start Wearing Purple</title>
		<link>http://www.temporaldisruption.com/2010/04/05/start-wearing-purple/</link>
		<comments>http://www.temporaldisruption.com/2010/04/05/start-wearing-purple/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 13:17:56 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[Colorado Rockies]]></category>
		<category><![CDATA[Eric Young Jr.]]></category>
		<category><![CDATA[Gogol Bordello]]></category>
		<category><![CDATA[Jorge de la Rosa]]></category>
		<category><![CDATA[Seth Smith]]></category>
		<category><![CDATA[Troy Tulowitzki]]></category>
		<category><![CDATA[Ubaldo Jimenez]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=617</guid>
		<description><![CDATA[Despite what may have appeared to be a diatribe against any team not in the AL East, I am in fact a Colorado Rockies fan. Though baseball season most definitely began last night, today begins the season for the Rockies. According to my most conservative, pessimistic, unbiased projections, the Rockies will finish the year with [...]]]></description>
			<content:encoded><![CDATA[<p><object width="500" height="405"><param name="movie" value="http://www.youtube.com/v/p_81l4DXlwM&#038;hl=en_US&#038;fs=1&#038;color1=0x402061&#038;color2=0x9461ca&#038;border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/p_81l4DXlwM&#038;hl=en_US&#038;fs=1&#038;color1=0x402061&#038;color2=0x9461ca&#038;border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="405"></embed></object></p>
<p>Despite <a href="http://www.temporaldisruption.com/2010/04/04/shut-up-you-nlal-central-loving-hillbillies/">what may have appeared to be a diatribe against any team not in the AL East</a>, I am in fact a Colorado Rockies fan.  Though <a href="http://www.temporaldisruption.com/2010/04/04/shut-up-you-nlal-central-loving-hillbillies/">baseball season most definitely began last night</a>, today begins the season for the Rockies.</p>
<p>According to my most conservative, pessimistic, unbiased projections, the Rockies will finish the year with a record of 133-29.  <a href="http://www.fangraphs.com/statss.aspx?playerid=3531&#038;position=SS">Troy Tulowitzki</a> will win the NL MVP unanimously, and <a href="http://www.fangraphs.com/statss.aspx?playerid=3374&#038;position=P">Ubaldo Jimenez</a> will win the NL Cy Young, just barely edging out <a href="http://www.fangraphs.com/statss.aspx?playerid=2047&#038;position=P">Jorge de la Rosa</a>.  And while we&#8217;re at it, let&#8217;s project <a href="http://www.fangraphs.com/statss.aspx?playerid=7158&#038;position=2B/OF">Eric Young Jr.</a> to win the NL Rookie of the Year award.</p>
<p>So Start Wearing Purple. And Free <a href="http://www.fangraphs.com/statss.aspx?playerid=7331&#038;position=OF">Seth Smith</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2010/04/05/start-wearing-purple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shut Up, You NL/AL Central Loving Hillbillies</title>
		<link>http://www.temporaldisruption.com/2010/04/04/shut-up-you-nlal-central-loving-hillbillies/</link>
		<comments>http://www.temporaldisruption.com/2010/04/04/shut-up-you-nlal-central-loving-hillbillies/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 23:07:28 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[Adrian Beltre]]></category>
		<category><![CDATA[Boston Red Sox]]></category>
		<category><![CDATA[Mike Cameron]]></category>
		<category><![CDATA[New York Yankees]]></category>
		<category><![CDATA[Nick Johnson]]></category>
		<category><![CDATA[opening day]]></category>
		<category><![CDATA[Sarah Palin]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=608</guid>
		<description><![CDATA[What is this nonsense I keep hearing from the mouths of fans of teams that play in the Flyover-State Divisions? Shit like, &#8220;tomorrow&#8217;s the real opening day&#8221; and &#8220;the real baseball season doesn&#8217;t start until tomorrow&#8221;. Sounds like an extension of Palin&#8217;s &#8220;real&#8221; America rhetoric to me. Listen up, hillbillies. Baseball season starts tonight, and [...]]]></description>
			<content:encoded><![CDATA[<p>What is this nonsense I keep hearing from the mouths of fans of teams that play in the Flyover-State Divisions?  Shit like, &#8220;tomorrow&#8217;s the <em>real</em> opening day&#8221; and &#8220;the <em>real</em> baseball season doesn&#8217;t start until tomorrow&#8221;.  Sounds like an extension of Palin&#8217;s &#8220;real&#8221; America rhetoric to me.</p>
<p>Listen up, hillbillies.  Baseball season starts tonight, and it&#8217;s gonna be played in the northeast between two blue state teams.  The Yankees are bringing back <a href="http://www.fangraphs.com/statss.aspx?playerid=828&#038;position=1B">Nick &#8220;The Stick&#8221; Johnson</a> and his .400 OBP, while the Red Sox are sporting a much improved defense, with <a href="http://www.southsidesox.com/2010/3/4/1335408/metaprimer-uzr">UZR</a> studs like <a href="http://www.fangraphs.com/statss.aspx?playerid=1070&#038;position=OF">Mike Cameron</a> and <a href="http://www.fangraphs.com/statss.aspx?playerid=639&#038;position=3B">Adrian Beltre</a>.  I know, I know.  Sabermetrics is part of a socialist plot, perpetrated by Ivy League elitists, like Theo Epstein.</p>
<p>So set up some lawn furniture and hook up an extension cord from your tv set to the car battery of your pickup truck, which is probably also parked on your lawn.  Get ready to see how baseball is played up here.  But make sure your shotgun is by your side, in case a U.S. Census worker shows up during the 7th inning stretch.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2010/04/04/shut-up-you-nlal-central-loving-hillbillies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s the OBP, Stupid!</title>
		<link>http://www.temporaldisruption.com/2010/01/01/its-the-obp-stupid/</link>
		<comments>http://www.temporaldisruption.com/2010/01/01/its-the-obp-stupid/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 23:51:27 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[Chris Iannetta]]></category>
		<category><![CDATA[Colorado Rockies]]></category>
		<category><![CDATA[Miguel Olivo]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=387</guid>
		<description><![CDATA[I hope the signing of Miguel Olivo truly does mean that the Rockies intend to give Chris Iannetta the full workload of a starting catcher. It&#8217;d be a shame if Jim Tracy and the Rockies organization was tempted to play Olivo more than necessary, considering he has a lifetime OBP of .278, compared to Iannetta&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I hope the signing of Miguel Olivo truly does mean that the Rockies intend to give Chris Iannetta the full workload of a starting catcher.  It&#8217;d be a shame if Jim Tracy and the Rockies organization was tempted to play Olivo more than necessary, considering he has a lifetime OBP of .278, compared to Iannetta&#8217;s .361.  If Iannetta gets the playing time he deserves, then I expect some <a href="http://www.fangraphs.com/fantasy/index.php/colorados-catching-situation/">nice fantasy value</a> from him out of the catcher spot. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2010/01/01/its-the-obp-stupid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rockies To Sign Miguel Olivo &#8211; Let the Good Iannetta Times Roll</title>
		<link>http://www.temporaldisruption.com/2009/12/30/rockies-to-sign-miguel-olivo-let-the-good-iannetta-times-roll/</link>
		<comments>http://www.temporaldisruption.com/2009/12/30/rockies-to-sign-miguel-olivo-let-the-good-iannetta-times-roll/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 01:00:00 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[Chris Iannetta]]></category>
		<category><![CDATA[Colorado Rockies]]></category>
		<category><![CDATA[Miguel Olivo]]></category>
		<category><![CDATA[Yorvit Torrealba]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=365</guid>
		<description><![CDATA[The Colorado Rockies are apparently close to a deal with catcher, Miguel Olivo. Rather than examining the strengths and weaknesses of the potential signing, I&#8217;m going to take the following from this news: the Rockies are done with Yorvit Torrealba! For the past three seasons, Chris Iannetta has had to share time behind the plate [...]]]></description>
			<content:encoded><![CDATA[<p>The Colorado Rockies are apparently <a href="http://www.purplerow.com/2009/12/30/1225827/report-rockies-close-to-deal-with">close to a deal</a> with catcher, Miguel Olivo.  Rather than examining the strengths and weaknesses of the potential signing, I&#8217;m going to take the following from this news: the Rockies are done with Yorvit Torrealba!</p>
<p>For the past three seasons, Chris Iannetta has had to share time behind the plate with Yorvit Torrealba, even though Iannetta is the superior player.  Not having Torrealba to stand in Iannetta&#8217;s way anymore makes me a happy Rockies fan.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2009/12/30/rockies-to-sign-miguel-olivo-let-the-good-iannetta-times-roll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Closers, Saves, and Alternate Realities</title>
		<link>http://www.temporaldisruption.com/2009/10/07/closers-saves-and-alternate-realities/</link>
		<comments>http://www.temporaldisruption.com/2009/10/07/closers-saves-and-alternate-realities/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:30:51 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[alternate universe]]></category>
		<category><![CDATA[closer]]></category>
		<category><![CDATA[Detroit Tigers]]></category>
		<category><![CDATA[Joe Nathan]]></category>
		<category><![CDATA[leverage index]]></category>
		<category><![CDATA[Minnesota Twins]]></category>
		<category><![CDATA[New York Yankees]]></category>
		<category><![CDATA[Richard Dawkins]]></category>
		<category><![CDATA[Ron Gardenhire]]></category>
		<category><![CDATA[save]]></category>
		<category><![CDATA[win probability]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=152</guid>
		<description><![CDATA[Up 5-4 against the Tigers in Game 163 last night, I thought Twins manager, Ron Gardenhire, should have used Joe Nathan to begin the top of the 8th inning. The Twins ended up winning the game anyway, so this may all be moot. But by using Nathan in the eighth from the outset, the Twins [...]]]></description>
			<content:encoded><![CDATA[<p>Up 5-4 against the Tigers in <a href="http://www.fangraphs.com/wins.aspx?date=2009-10-06&#038;team=Twins&#038;dh=0">Game 163</a> last night, I thought Twins manager, Ron Gardenhire, should have used Joe Nathan to begin the top of the 8th inning.  The Twins ended up winning the game anyway, so this may all be moot.  But by using Nathan in the eighth from the outset, the Twins could have prevented blowing the lead in the eighth, had an easier path to victory and avoided extra innings.</p>
<p>First of all, Nathan ended up coming in with one out in the eighth and pitched 1.2 innings in the game, so Gardenhire clearly had no problem using Nathan in the eighth or having him go more than one inning.  But even if Gardenhire only wanted to use Nathan for one inning, I think that the eighth, with Ordonez, Cabrera, and Guillen &#8211; arguably the best part of Detroit&#8217;s lineup &#8211; due up, would have made more sense than the ninth.</p>
<p>This isn&#8217;t a new argument &#8211; I even think I&#8217;ve heard Joe Morgan make it.  I&#8217;m more interested in why the fans, media and baseball community as a whole think that a team&#8217;s best reliever needs to be saved for the ninth inning (and I&#8217;m sure we can all agree that Joe Nathan is the Twins&#8217; best reliever).</p>
<p>About two years ago, I found myself making this argument to my uncle, who&#8217;s a more casual, conventional baseball fan.  I gave him the hypothetical, &#8220;What if the Yankees have a one-run lead on the Red Sox with Manny and Ortiz due up in the eighth inning?  Wouldn&#8217;t you rather have Mariano Rivera pitch to them in the eighth than pitch to the bottom of the Red Sox order in the ninth?&#8221; (my uncle is a Yankee fan, btw).  He responded, &#8220;Yeah, but there&#8217;s just something about pitching in the ninth to finish a game&#8221;.  By &#8220;something&#8221;, he most likely meant that the ninth inning is a &#8220;pressure&#8221; situation, and only a certain type of reliever, like Mariano Rivera, can overcome that &#8220;pressure&#8221;.  What I&#8217;m trying to figure out is whether this hypothetical ninth should present more &#8220;pressure&#8221; than the hypothetical eighth, and why we don&#8217;t think an eighth inning like this deserves a feeling of &#8220;pressure&#8221;.</p>
<p>First, lets examine the situations presented in the eighth and ninth innings of last night&#8217;s Twins-Tigers game.  According to <a href="http://www.insidethebook.com/">The Book</a>, a team leading by one run in the top of the eighth with nobody on and nobody out ends up winning the game with a probability of .734.  Other relevant win probabilities:</p>
<blockquote><p>Bot 8, up by 1, nobody on, nobody out: .861<br />
Top 9, up by 1, nobody on, nobody out: .825<br />
Bot 9, up by 1, nobody on, nobody out: 1.00 (obviously)</p></blockquote>
<p>All win probabilities assume average pitchers and batters in every situation.  So, a player pitching a scoreless eighth inning in last night&#8217;s game could have increased the Twins&#8217; win probability by .127 (.861 &#8211; .734).  Similarly, a player pitching a scoreless ninth up by one run, presumably the situation Gardenhire was saving Nathan for, could have increased the Twins&#8217; win probability by .175 (1.00 &#8211; .825).  The ninth, in this case, is a more important situation by .048 (.175 &#8211; .127).  But do the hitters faced in the eighth make up for the difference of .048 in win probability added?  I think it does, but let&#8217;s take a closer look.</p>
<p>In the eighth, the Twins were set to face Ordonez, Cabrera, Guillen, and, if anyone got on, Raburn.  Here are the AVG/OBP/SLG/wOBA stats for those players:</p>
<blockquote><p>
Ordonez	.310/.376/.428/.356<br />
Cabrera	.324/.396/.547/.402<br />
Guillen	.242/.339/.419/.328<br />
Raburn	.291/.359/.533/.378
</p></blockquote>
<p>Due up in the ninth were Raburn, if no one reached in the eight, followed by Inge, Laird and Santiago.  Here are their slash stats:</p>
<blockquote><p>
Raburn	.291/.359/.533/.378<br />
Inge		.230/.314/.406/.315<br />
Laird		.225/.306/.320/.287<br />
Santiago	.267/.318/.385/.307
</p></blockquote>
<p>The first group of hitters are clearly superior to the second group.  To be honest, I don&#8217;t know how to calculate the exact difference in win probability between the two groups, but I assume that the superior level of talent of the first group is enough to overcome the win probability of .048.  Even if it is not, and I am incorrect about using Nathan in the eighth, one can easily conceive of situations in which one group of hitters is enough to overcome such a difference, and this discussion would be of relevance.</p>
<p>If we make the assumption that the hitters due up in the top of the eighth made that half inning a higher leverage situation than the top of the ninth, it begs the question, &#8220;Why would managers save their best relief pitcher for a lower leverage ninth inning?&#8221;.  One obvious reason is MLB&#8217;s official save statistic.  Pitchers only receive a SV when they record the last out in the game, and closers have come to be judged, evaluated and paid through incentives based on the save statistic.  In some ways, MLB managers have become a slave to the SV statistic.</p>
<p>Another possible reason for the false sense of &#8220;pressure&#8221; in the ninth comes from familiar dramatic structures seen in television, film, and literature where the entire plot line builds towards a climax at the end.  We tend to project this structure onto other aspects of life, including baseball games.  We therefore assume that the climax, or most important moment, happens in the last inning, even when this is not mathematically the case.</p>
<p>I present to you now, an alternate universe in which relief pitchers, fans, the media, and baseball managers feel the appropriate amount of &#8220;pressure&#8221; at appropriate times within the course of a baseball game.  This alternate universe differs from our own universe in only two ways: the SV statistic does not exist, and announcers consistently discuss things like leverage index and win probability (in a way that&#8217;s not too nerdy for casual fans) while announcing baseball games.</p>
<p>Without a SV stat, relief pitchers would feel less pressure to record a save or accumulate a badge of honor or notch on their belt when pitching the ninth.  These pitchers would also be more willing to pitch the eighth or seventh inning without feeling like they were depreciating their own value or leverage for future contract negotiations.</p>
<p>To explain the effect of announcers discussing things like win probability, I turn to a discussion within Richard Dawkins&#8217;, <a href="http://richarddawkins.net/godDelusion">The God Delusion</a>.  In explaining how evolution and experience shapes our understanding of our world, Dawkins writes:</p>
<blockquote><p>&#8220;Unaided human intuition, evolved and schooled in [our world], even finds it hard to believe Galileo when he tells us that a cannonball and a feather, given no air friction, would hit the ground at the same instant when dropped from a leaning tower.  That is because, in [our world], air friction is always there.  If we had evolved in a vacuum, we would expect a feather and a cannonball to hit the ground simultaneously.  We are evolved denizens of [this world] and that limits what we are capable of imagining.&#8221;</p></blockquote>
<p>Just how living in a world with no air friction would allow us to understand a feather and cannonball falling at the same speed without any stretch of the imagination, growing up in a world where announcers regularly discuss the implications of win probability would allow us to accept using a team&#8217;s best relief pitcher in a high leverage situation in the seventh or eighth inning.  In this alternate universe, relievers and managers would feel more &#8220;pressure&#8221; in high leverage situations in middle innings than they would feel in low leverage ninth innings that we consider &#8220;save situations&#8221;.  In such a universe, Joe Nathan may have pitched the eighth last night and held the lead heading into the ninth.  In such a universe, the Twins may have avoided extra innings.  In such a universe, the Twins may have been more well-rested heading into tonight&#8217;s game against the Yankees.  And in such a universe, the Twins may have had a better chance of beating the Yankees in the ALDS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2009/10/07/closers-saves-and-alternate-realities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calculating FIP and WAR from Retrosheet Data, Part 1</title>
		<link>http://www.temporaldisruption.com/2009/08/31/calculating-fip-and-war-from-retrosheet-data-part-1/</link>
		<comments>http://www.temporaldisruption.com/2009/08/31/calculating-fip-and-war-from-retrosheet-data-part-1/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 19:17:47 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[FIP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[park factor]]></category>
		<category><![CDATA[retrosheet]]></category>
		<category><![CDATA[WAR]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=48</guid>
		<description><![CDATA[Ok, I finally have the beginnings (Finally have the beginnings? That doesn&#8217;t sound right.) of FIP and WAR calculations for starting pitchers. After parsing pitching data out of retrosheet files from the 2007 season, I calculated FIP and WAR for SP on a per-game level. By taking a weighted average of these game-level FIP and [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I finally have the beginnings (Finally have the beginnings? That doesn&#8217;t sound right.) of FIP and WAR calculations for starting pitchers.  After parsing pitching data out of retrosheet files from the 2007 season, I calculated FIP and WAR for SP on a per-game level.  By taking a weighted average of these game-level FIP and WAR values, one can derive a pitcher&#8217;s FIP and WAR for an entire season.</p>
<p><a href="http://www.bryanpackman.com/blog/2009/08/27/park-factors/">In a previous post</a>, I mentioned my intent to update such metrics after parsing each event from a retrosheet file or a stats feed.  Though I intend to eventually update these metrics in &#8220;real-time&#8221;, I am currently calculating FIP and WAR after parsing an entire season&#8217;s worth of data.  For now, I want to get these values into a database and make sure my math is correct.  Once done, I&#8217;ll go back and optimize things so that FIP, WAR, and other stats can update with each relevant event.</p>
<p>I&#8217;ll now go through the process in detail, using James Shields&#8217; 2007 season as an example.  Before going through the details, here are a few disclaimers:
<ol>
<li>This is my first attempt at calculating FIP and WAR, and I am by no means an expert on the process.  I make a few assumptions, which I will explain, that may be incorrect.  If I find out that any of these assumptions are wrong, I&#8217;ll go back and update this post with the corrections.</li>
<li>MySQL tables are NOT optimized for displaying leaderboards or other practical uses.  Optimizing tables will be an ongoing process.</li>
</ol>
<p>My parsing script places a starting pitcher&#8217;s stats for an individual game into a table with the following structure:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">CREATE</span> <span class="kw1">TABLE</span> <span class="st0">`pitcher_game_start`</span> <span class="br0">&#40;</span><br />
&nbsp; <span class="st0">`rs_game_id`</span> char<span class="br0">&#40;</span>12<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`rs_player_id`</span> char<span class="br0">&#40;</span>8<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`rs_park_id`</span> char<span class="br0">&#40;</span>5<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`rs_league_id`</span> char<span class="br0">&#40;</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`rs_team_id`</span> char<span class="br0">&#40;</span>3<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`year`</span> smallint<span class="br0">&#40;</span>6<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`HR`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`BB`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`HBP`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`IBB`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`SO`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`ER`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`R`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`IP_outs`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">PRIMARY</span> <span class="kw1">KEY</span> &nbsp;<span class="br0">&#40;</span><span class="st0">`rs_player_id`</span><span class="sy0">,</span><span class="st0">`rs_game_id`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`year_league`</span> <span class="br0">&#40;</span><span class="st0">`year`</span><span class="sy0">,</span><span class="st0">`rs_league_id`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`park_year`</span> <span class="br0">&#40;</span><span class="st0">`rs_park_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`game_id`</span> <span class="br0">&#40;</span><span class="st0">`rs_game_id`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`pylt`</span> <span class="br0">&#40;</span><span class="st0">`rs_player_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="sy0">,</span><span class="st0">`rs_league_id`</span><span class="sy0">,</span><span class="st0">`rs_team_id`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`tly`</span> <span class="br0">&#40;</span><span class="st0">`rs_team_id`</span><span class="sy0">,</span><span class="st0">`rs_park_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`ty`</span> <span class="br0">&#40;</span><span class="st0">`rs_team_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> ENGINE<span class="sy0">=</span>MyISAM</div>
</div>
<p>A field of significant interest is `rs_league_id`.  This field describes the league of the home team.  <strong>For interleague games, the home team&#8217;s league will be used for the pitchers on both sides</strong>.  Additionally, the league average ERA and RA, both used in calculating FIP and WAR, will be based on the home team&#8217;s league.</p>
<p>Here are Shields&#8217; rows in `pitcher_game_start` for 2007:</p>
<div class="codesnip-container" >
<table>
<tr>
<td>rs_game_id</td>
<td>rs_player_id</td>
<td>rs_park_id</td>
<td>rs_league_id</td>
<td>rs_team_id</td>
<td>year</td>
<td>HR</td>
<td>BB</td>
<td>HBP</td>
<td>IBB</td>
<td>SO</td>
<td>ER</td>
<td>R</td>
<td>IP_outs</td>
</tr>
<tr>
<td>SEA200709140</td>
<td>shiej002</td>
<td>SEA03</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>1</td>
<td>1</td>
<td>24</td>
</tr>
<tr>
<td>TBA200709090</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>2</td>
<td>2</td>
<td>21</td>
</tr>
<tr>
<td>TBA200709030</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>6</td>
<td>1</td>
<td>4</td>
<td>21</td>
</tr>
<tr>
<td>BAL200708290</td>
<td>shiej002</td>
<td>BAL12</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>6</td>
<td>4</td>
<td>4</td>
<td>24</td>
</tr>
<tr>
<td>TBA200708240</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>8</td>
<td>2</td>
<td>2</td>
<td>25</td>
</tr>
<tr>
<td>TBA200708190</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>6</td>
<td>2</td>
<td>2</td>
<td>18</td>
</tr>
<tr>
<td>BOS200708130</td>
<td>shiej002</td>
<td>BOS07</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>1</td>
<td>1</td>
<td>18</td>
</tr>
<tr>
<td>DET200708080</td>
<td>shiej002</td>
<td>DET05</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>9</td>
<td>1</td>
<td>1</td>
<td>21</td>
</tr>
<tr>
<td>TBA200708030</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>6</td>
<td>3</td>
<td>3</td>
<td>20</td>
</tr>
<tr>
<td>TBA200707280</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>7</td>
<td>3</td>
<td>3</td>
<td>15</td>
</tr>
<tr>
<td>NYA200707220</td>
<td>shiej002</td>
<td>NYC16</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>4</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>10</td>
<td>10</td>
<td>10</td>
</tr>
<tr>
<td>TBA200707170</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>2</td>
<td>2</td>
<td>2</td>
<td>21</td>
</tr>
<tr>
<td>TBA200707120</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>2</td>
<td>5</td>
<td>6</td>
<td>18</td>
</tr>
<tr>
<td>KCA200707060</td>
<td>shiej002</td>
<td>KAN06</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>6</td>
<td>4</td>
<td>4</td>
<td>23</td>
</tr>
<tr>
<td>CLE200707010</td>
<td>shiej002</td>
<td>CLE08</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>10</td>
<td>2</td>
<td>3</td>
<td>19</td>
</tr>
<tr>
<td>TBA200706260</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>11</td>
<td>5</td>
<td>5</td>
<td>21</td>
</tr>
<tr>
<td>ARI200706200</td>
<td>shiej002</td>
<td>PHO01</td>
<td>NL</td>
<td>TBA</td>
<td>2007</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>4</td>
<td>6</td>
<td>6</td>
<td>15</td>
</tr>
<tr>
<td>COL200706150</td>
<td>shiej002</td>
<td>DEN02</td>
<td>NL</td>
<td>TBA</td>
<td>2007</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>2</td>
<td>5</td>
<td>5</td>
<td>18</td>
</tr>
<tr>
<td>FLO200706090</td>
<td>shiej002</td>
<td>MIA01</td>
<td>NL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>0</td>
<td>2</td>
<td>0</td>
<td>9</td>
<td>2</td>
<td>2</td>
<td>21</td>
</tr>
<tr>
<td>TBA200706040</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>2</td>
<td>2</td>
<td>22</td>
</tr>
<tr>
<td>TBA200705300</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>3</td>
<td>3</td>
<td>27</td>
</tr>
<tr>
<td>CHA200705250</td>
<td>shiej002</td>
<td>CHI12</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>3</td>
<td>2</td>
<td>0</td>
<td>2</td>
<td>4</td>
<td>4</td>
<td>21</td>
</tr>
<tr>
<td>TBA200705200</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>3</td>
<td>0</td>
<td>0</td>
<td>8</td>
<td>1</td>
<td>1</td>
<td>21</td>
</tr>
<tr>
<td>TBA200705150</td>
<td>shiej002</td>
<td>LBV01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>3</td>
<td>3</td>
<td>24</td>
</tr>
<tr>
<td>BAL200705090</td>
<td>shiej002</td>
<td>BAL12</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>4</td>
<td>0</td>
<td>0</td>
<td>27</td>
</tr>
<tr>
<td>TBA200705030</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>8</td>
<td>3</td>
<td>3</td>
<td>22</td>
</tr>
<tr>
<td>OAK200704270</td>
<td>shiej002</td>
<td>OAK01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>9</td>
<td>1</td>
<td>1</td>
<td>24</td>
</tr>
<tr>
<td>TBA200704220</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>12</td>
<td>2</td>
<td>2</td>
<td>24</td>
</tr>
<tr>
<td>TBA200704160</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>2</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>5</td>
<td>5</td>
<td>19</td>
</tr>
<tr>
<td>TEX200704110</td>
<td>shiej002</td>
<td>ARL02</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>8</td>
<td>4</td>
<td>5</td>
<td>21</td>
</tr>
<tr>
<td>TBA200704060</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>0</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>3</td>
<td>3</td>
<td>3</td>
<td>20</td>
</tr>
</table>
</div>
<p>Next, I created a table for league constants with the following structure:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">CREATE</span> <span class="kw1">TABLE</span> <span class="st0">`league_constants`</span> <span class="br0">&#40;</span><br />
&nbsp; <span class="st0">`rs_league_id`</span> char<span class="br0">&#40;</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`year`</span> smallint<span class="br0">&#40;</span>6<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`league_constant_name`</span> varchar<span class="br0">&#40;</span>32<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`league_constant_value`</span> float<span class="br0">&#40;</span>8<span class="sy0">,</span>3<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span> <span class="kw1">DEFAULT</span> <span class="st0">&#8217;0.000&#8242;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">PRIMARY</span> <span class="kw1">KEY</span> &nbsp;<span class="br0">&#40;</span><span class="st0">`rs_league_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="sy0">,</span><span class="st0">`league_constant_name`</span><span class="br0">&#40;</span>8<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`year`</span> <span class="br0">&#40;</span><span class="st0">`year`</span><span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> ENGINE<span class="sy0">=</span>MyISAM</div>
</div>
<p>The constants I am concerned with for these calculations are: ERA, RA, and FIP_ERA.  ERA and RA are the league average ERA and RA, and FIP_ERA is the constant used to translate the league average ERA to the league average FIP.  I ran the following script to populate the table with said constants:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw2">&lt;?php</span></p>
<p><span class="re0">$sql</span> <span class="sy0">=</span> <br />
<span class="st0">&quot;SELECT &nbsp;`year`, `rs_league_id`, <br />
&nbsp; SUM(9*`ER`) / (SUM(`IP_outs`) / 3) &nbsp;as sp_era, <br />
&nbsp; SUM(9*`R`) / (SUM(`IP_outs`) / 3) &nbsp;as sp_ra,<br />
&nbsp; SUM(9*`ER` + 2*`SO` &#8211; 3*(`BB`-`IBB`+`HBP`) &#8211; 13*`HR`) / (SUM(`IP_outs`) / 3) AS sp_fip_era<br />
FROM `pitcher_game_start` <br />
FORCE INDEX (`year_league`)<br />
GROUP BY `year`, `rs_league_id`&quot;</span><span class="sy0">;</span><br />
<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="sy0">,</span> <span class="re0">$link</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="re0">$inserts</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="re0">$res</span> <span class="sy0">=</span> <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="sy0">,</span> <span class="re0">$link</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="re0">$row</span> <span class="sy0">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span class="kw3">mysql_fetch_assoc</span></a><span class="br0">&#40;</span><span class="re0">$res</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="re0">$league</span> <span class="sy0">=</span> <span class="re0">$row</span><span class="br0">&#91;</span><span class="st_h">&#8216;rs_league_id&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$year</span> <span class="sy0">=</span> <span class="re0">$row</span><span class="br0">&#91;</span><span class="st_h">&#8216;year&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <a href="http://www.php.net/unset"><span class="kw3">unset</span></a><span class="br0">&#40;</span><span class="re0">$row</span><span class="br0">&#91;</span><span class="st_h">&#8216;rs_league_id&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <a href="http://www.php.net/unset"><span class="kw3">unset</span></a><span class="br0">&#40;</span><span class="re0">$row</span><span class="br0">&#91;</span><span class="st_h">&#8216;year&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; <span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$row</span> <span class="kw1">as</span> <span class="re0">$key</span> <span class="sy0">=&gt;</span> <span class="re0">$value</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$inserts</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st0">&quot;(&#8216;<span class="es4">$league</span>&#8216;, &#8216;<span class="es4">$year</span>&#8216;, &#8216;<span class="es4">$key</span>&#8216;, &#8216;<span class="es4">$value</span>&#8216;)&quot;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="re0">$sql</span> <span class="sy0">=</span> <br />
<span class="st0">&quot;INSERT IGNORE INTO `league_constants` (`rs_league_id`,`year`,`league_constant_name`, `league_constant_value`) <br />
VALUES &quot;</span> <span class="sy0">.</span> <a href="http://www.php.net/implode"><span class="kw3">implode</span></a><span class="br0">&#40;</span><span class="st_h">&#8216;,&#8217;</span><span class="sy0">,</span> <span class="re0">$inserts</span><span class="br0">&#41;</span> <span class="sy0">.</span> <span class="st0">&quot;<br />
ON DUPLICATE KEY UPDATE `league_constant_value` = VALUES(`league_constant_value`)&quot;</span><span class="sy0">;</span><br />
<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="sy0">,</span> <span class="re0">$link</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>And here are the values in the table:</p>
<div class="codesnip-container" >
<table>
<tr>
<td>rs_league_id</td>
<td>year</td>
<td>league_constant_name</td>
<td>league_constant_value</td>
</tr>
<tr>
<td>AL</td>
<td>2007</td>
<td>sp_era</td>
<td>4.686</td>
</tr>
<tr>
<td>AL</td>
<td>2007</td>
<td>sp_ra</td>
<td>5.064</td>
</tr>
<tr>
<td>AL</td>
<td>2007</td>
<td>sp_fip_era</td>
<td>3.408</td>
</tr>
<tr>
<td>NL</td>
<td>2007</td>
<td>sp_era</td>
<td>4.567</td>
</tr>
<tr>
<td>NL</td>
<td>2007</td>
<td>sp_ra</td>
<td>4.909</td>
</tr>
<tr>
<td>NL</td>
<td>2007</td>
<td>sp_fip_era</td>
<td>3.280</td>
</tr>
</table>
</div>
<p><strong>All league constants are derived from innings pitched solely by starting pitchers</strong>.  When calculating WAR for RP, probably in a later post, I&#8217;ll use another set of constants that averages values from innings pitched by relievers.</p>
<p>Now, we have everything we need to start calculating FIP and WAR for each game.  I used <a href="http://www.fangraphs.com/blogs/index.php/pitcher-win-values-explained-part-seven">Dave Cameron&#8217;s 7-part description</a> of WAR on fangraphs as a guide.  I created the following table to store game details for starting pitcher&#8217;s along with calculated FIPs and WARs:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">CREATE</span> <span class="kw1">TABLE</span> <span class="st0">`pitcher_game_start_fip`</span> <span class="br0">&#40;</span><br />
&nbsp; <span class="st0">`rs_game_id`</span> char<span class="br0">&#40;</span>12<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`rs_player_id`</span> char<span class="br0">&#40;</span>8<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`rs_park_id`</span> char<span class="br0">&#40;</span>5<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`rs_league_id`</span> char<span class="br0">&#40;</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`rs_team_id`</span> char<span class="br0">&#40;</span>3<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`year`</span> smallint<span class="br0">&#40;</span>6<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`IP_outs`</span> tinyint<span class="br0">&#40;</span>4<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`PF`</span> float<span class="br0">&#40;</span>5<span class="sy0">,</span>3<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span> <span class="kw1">DEFAULT</span> <span class="st0">&#8217;1.000&#8242;</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`fip_era_const`</span> float<span class="br0">&#40;</span>5<span class="sy0">,</span>3<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span> <span class="kw1">DEFAULT</span> <span class="st0">&#8217;0.000&#8242;</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`avg_era`</span> float<span class="br0">&#40;</span>5<span class="sy0">,</span>3<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span> <span class="kw1">DEFAULT</span> <span class="st0">&#8217;0.000&#8242;</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`avg_ra`</span> float<span class="br0">&#40;</span>5<span class="sy0">,</span>3<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span> <span class="kw1">DEFAULT</span> <span class="st0">&#8217;0.000&#8242;</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`ERA`</span> float<span class="br0">&#40;</span>4<span class="sy0">,</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`base_fip`</span> float<span class="br0">&#40;</span>4<span class="sy0">,</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`FIP`</span> float<span class="br0">&#40;</span>4<span class="sy0">,</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`fip_ra`</span> float<span class="br0">&#40;</span>4<span class="sy0">,</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`fip_ra_prk`</span> float<span class="br0">&#40;</span>4<span class="sy0">,</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`R_per_W`</span> float<span class="br0">&#40;</span>5<span class="sy0">,</span>3<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span> <span class="kw1">DEFAULT</span> <span class="st0">&#8217;0.000&#8242;</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`RAR`</span> float<span class="br0">&#40;</span>4<span class="sy0">,</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="st0">`WAR`</span> float<span class="br0">&#40;</span>4<span class="sy0">,</span>2<span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">PRIMARY</span> <span class="kw1">KEY</span> &nbsp;<span class="br0">&#40;</span><span class="st0">`rs_player_id`</span><span class="sy0">,</span><span class="st0">`rs_game_id`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`year_league`</span> <span class="br0">&#40;</span><span class="st0">`year`</span><span class="sy0">,</span><span class="st0">`rs_league_id`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`park_year`</span> <span class="br0">&#40;</span><span class="st0">`rs_park_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`game_id`</span> <span class="br0">&#40;</span><span class="st0">`rs_game_id`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`pylt`</span> <span class="br0">&#40;</span><span class="st0">`rs_player_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="sy0">,</span><span class="st0">`rs_league_id`</span><span class="sy0">,</span><span class="st0">`rs_team_id`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`tly`</span> <span class="br0">&#40;</span><span class="st0">`rs_team_id`</span><span class="sy0">,</span><span class="st0">`rs_park_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="kw1">KEY</span> <span class="st0">`ty`</span> <span class="br0">&#40;</span><span class="st0">`rs_team_id`</span><span class="sy0">,</span><span class="st0">`year`</span><span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> ENGINE<span class="sy0">=</span>MyISAM</div>
</div>
<p>The first step is to insert the general game info, as well as PF, ERA, and base_fip columns into the table.  </p>
<ul>
<li>PF (park factor) comes from another table called, park_effects. </li>
<li>If not already obvious, ERA = (ER*9) / (IP_outs/3)</li>
<li>base_fip = (-2*SO + 3*(BB-IBB+HBP) + 13*HR) / (IP_outs/3)</li>
</ul>
<p>I used the following code snippet to populate those values:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span> <span class="sy0">=</span> <span class="nu0">2007</span><span class="sy0">;</span> <span class="re0">$i</span> <span class="sy0">&lt;=</span> <span class="nu0">2007</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span><span class="br0">&#123;</span></p>
<p>&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; <span class="co1">//basic info, ERA, base_fip, PF</span><br />
&nbsp; <span class="re0">$sql</span> <span class="sy0">=</span> <br />
&nbsp; <span class="st0">&quot;INSERT IGNORE INTO `pitcher_game_start_fip` (`rs_game_id`, `rs_player_id`, `rs_park_id`, `rs_league_id`, `rs_team_id`, `year`, `IP_outs`, `PF`, `ERA`, `base_fip`)<br />
&nbsp; SELECT<br />
&nbsp; &nbsp; s.`rs_game_id`, s.`rs_player_id`, s.`rs_park_id`, s.`rs_league_id`, s.`rs_team_id`, s.`year`, s.`IP_outs`,<br />
&nbsp; &nbsp; p.`PF`, <br />
&nbsp; &nbsp; (s.`ER`*9) / (s.`IP_outs`/3) as ERA, <br />
&nbsp; &nbsp; (-2*s.`SO` + 3*(s.`BB`-s.`IBB`+s.`HBP`) + 13*s.`HR`) / (s.`IP_outs`/3) as base_fip<br />
&nbsp; &nbsp; FROM `pitcher_game_start` s <br />
&nbsp; &nbsp; LEFT JOIN `games` g ON s.`rs_game_id` = g.`rs_game_id`<br />
&nbsp; &nbsp; LEFT JOIN `park_effects` p ON s.`rs_park_id` = p.`rs_park_id` AND s.`year` = p.`year` AND g.`rs_home_team_id` = p.`rs_team_id`<br />
&nbsp; &nbsp; WHERE s.`year` = <span class="es4">$i</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="sy0">,</span> <span class="re0">$link</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">.</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>Next, I populated the table with the appropriate values for league average ERA, league average RA, and the league constant used to translate ERA to FIP.  I used values from the `league_constants` table, calculated earlier, with the following piece of code:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span> <span class="sy0">=</span> <span class="nu0">2007</span><span class="sy0">;</span> <span class="re0">$i</span> <span class="sy0">&lt;=</span> <span class="nu0">2007</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="co1">//get league constants</span><br />
&nbsp; <span class="re0">$league_consts</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$sql</span> <span class="sy0">=</span> <span class="st0">&quot;SELECT * FROM `league_constants` WHERE `year` = <span class="es4">$i</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$res</span> <span class="sy0">=</span> <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="sy0">,</span> <span class="re0">$link</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">while</span><span class="br0">&#40;</span><span class="re0">$row</span> <span class="sy0">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span class="kw3">mysql_fetch_assoc</span></a><span class="br0">&#40;</span><span class="re0">$res</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$league_consts</span><span class="br0">&#91;</span><span class="re0">$row</span><span class="br0">&#91;</span><span class="st_h">&#8216;rs_league_id&#8217;</span><span class="br0">&#93;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="re0">$row</span><span class="br0">&#91;</span><span class="st_h">&#8216;league_constant_name&#8217;</span><span class="br0">&#93;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="re0">$row</span><span class="br0">&#91;</span><span class="st_h">&#8216;league_constant_value&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; <span class="co1">//fip_era_const, avg_era, avg_ra</span><br />
&nbsp; <span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$league_consts</span> <span class="kw1">as</span> <span class="re0">$league_id</span> <span class="sy0">=&gt;</span> <span class="re0">$consts</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$sql</span> <span class="sy0">=</span> <br />
&nbsp; &nbsp; <span class="st0">&quot;UPDATE `pitcher_game_start_fip` <br />
&nbsp; &nbsp; &nbsp; SET<br />
&nbsp; &nbsp; &nbsp; &nbsp; `fip_era_const` = &#8216;&quot;</span><span class="sy0">.</span><span class="re0">$consts</span><span class="br0">&#91;</span><span class="st_h">&#8216;sp_fip_era&#8217;</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st0">&quot;&#8217;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; `avg_era` = &#8216;&quot;</span><span class="sy0">.</span><span class="re0">$consts</span><span class="br0">&#91;</span><span class="st_h">&#8216;sp_era&#8217;</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st0">&quot;&#8217;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; `avg_ra` = &#8216;&quot;</span><span class="sy0">.</span><span class="re0">$consts</span><span class="br0">&#91;</span><span class="st_h">&#8216;sp_ra&#8217;</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st0">&quot;&#8217;<br />
&nbsp; &nbsp; &nbsp; WHERE <br />
&nbsp; &nbsp; &nbsp; &nbsp; `year` = &#8216;.<span class="es4">$i</span>.&#8217; AND<br />
&nbsp; &nbsp; &nbsp; &nbsp; `rs_league_id` = &#8216;&quot;</span><span class="sy0">.</span><span class="re0">$league_id</span><span class="sy0">.</span><span class="st0">&quot;&#8217;&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="sy0">,</span> <span class="re0">$link</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>And now, calculate FIP and WAR for the starting pitcher of each game.  Here are the necessary formulas:</p>
<ol>
<li>Calculate FIP by adding the league FIP constant to the pitcher&#8217;s base FIP:<br />
FIP  = base_fip + fip_era_const</li>
<li>Turn FIP into a value reflecting runs rather than earned runs.  To do so, multiply FIP by the league RA/ERA ratio:<br />
fip_ra = FIP * (avg_ra/avg_era)</li>
<li>Adjust fip_ra to the park setting:<br />
fip_ra_prk = fip_ra / PF</li>
<li>Calculate how many runs are required to win in the current setting.  This is formula comes from Tango&#8217;s +2*1.5 formula: ((League RA + Pitcher’s RA)/2)+2)*1.5<br />
R_per_W = (((((54-IP_outs)*avg_ra) + (IP_outs*fip_ra_prk)) / 54) + 2) * 1.5</li>
<li>And finally, calculate WAR.  An average starter has a winning% of .500.  A replacement level starter has a winning percentage of .380% (.12 less than .500).  So, if we calculate the pitcher&#8217;s wins above replacement, multiplied by IP/9 inning game, we get WAR for the game in question:<br />
WAR = ((.12 + ((avg_ra &#8211; fip_ra_prk) / R_per_W)) * (IP_outs/3)) / 9</li>
</ol>
<p>Here&#8217;s the last part of the script, making the above calculations.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span> <span class="sy0">=</span> <span class="nu0">2007</span><span class="sy0">;</span> <span class="re0">$i</span> <span class="sy0">&lt;=</span> <span class="nu0">2007</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span><br />
&nbsp; <span class="sy0">.</span> &nbsp; &nbsp; <br />
&nbsp; <span class="co1">//calculate FIP, fip_ra, fip_ra_prk, R_per_W, WAR, RAR</span><br />
&nbsp; <span class="re0">$sql</span> <span class="sy0">=</span> <br />
&nbsp; <span class="st0">&quot;UPDATE `pitcher_game_start_fip` <br />
&nbsp; &nbsp; SET<br />
&nbsp; &nbsp; &nbsp; `FIP` = @fip:= (`base_fip` + `fip_era_const`),<br />
&nbsp; &nbsp; &nbsp; `fip_ra` = @fip_ra:= ((@fip * avg_ra) / avg_era),<br />
&nbsp; &nbsp; &nbsp; `fip_ra_prk` = @frp:= (@fip_ra / `PF`),<br />
&nbsp; &nbsp; &nbsp; `R_per_W` = @rpw:= ((( &nbsp;( ((54-`IP_outs`)*`avg_ra`) + (`IP_outs`*@frp) ) / 54) + 2) * 1.5),<br />
&nbsp; &nbsp; &nbsp; `WAR` = @war:= (((.12 + ((`avg_ra` &#8211; @frp) / @rpw)) * (`IP_outs`/3)) / 9), <br />
&nbsp; &nbsp; &nbsp; `RAR` = @war * @rpw<br />
&nbsp; &nbsp; WHERE `year` = &quot;</span><span class="sy0">.</span><span class="re0">$i</span><span class="sy0">;</span><br />
&nbsp; <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="sy0">,</span> <span class="re0">$link</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>And here are the results for starts by James Shields:</p>
<div class="codesnip-container" >
<table>
<tr>
<td>rs_game_id</td>
<td>rs_player_id</td>
<td>rs_park_id</td>
<td>rs_league_id</td>
<td>rs_team_id</td>
<td>year</td>
<td>IP_outs</td>
<td>PF</td>
<td>fip_era_const</td>
<td>avg_era</td>
<td>avg_ra</td>
<td>fip_ra_const</td>
<td>ERA</td>
<td>base_fip</td>
<td>FIP</td>
<td>fip_ra</td>
<td>fip_ra_prk</td>
<td>R_per_W</td>
<td>RAR</td>
<td>WAR</td>
</tr>
<tr>
<td>SEA200709140</td>
<td>shiej002</td>
<td>SEA03</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>24</td>
<td>0.948</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>1.12</td>
<td>-0.50</td>
<td>2.91</td>
<td>3.14</td>
<td>3.31</td>
<td>9.430</td>
<td>2.56</td>
<td>0.27</td>
</tr>
<tr>
<td>TBA200709090</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>2.57</td>
<td>0.43</td>
<td>3.84</td>
<td>4.15</td>
<td>4.73</td>
<td>10.404</td>
<td>1.23</td>
<td>0.12</td>
</tr>
<tr>
<td>TBA200709030</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>1.29</td>
<td>-1.29</td>
<td>2.12</td>
<td>2.29</td>
<td>2.61</td>
<td>9.166</td>
<td>2.76</td>
<td>0.30</td>
</tr>
<tr>
<td>BAL200708290</td>
<td>shiej002</td>
<td>BAL12</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>24</td>
<td>1.109</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>4.50</td>
<td>0.88</td>
<td>4.29</td>
<td>4.63</td>
<td>4.18</td>
<td>10.006</td>
<td>1.85</td>
<td>0.19</td>
</tr>
<tr>
<td>TBA200708240</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>25</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>2.16</td>
<td>0.00</td>
<td>3.41</td>
<td>3.68</td>
<td>4.20</td>
<td>9.999</td>
<td>1.91</td>
<td>0.19</td>
</tr>
<tr>
<td>TBA200708190</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>18</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>3.00</td>
<td>-1.50</td>
<td>1.91</td>
<td>2.06</td>
<td>2.35</td>
<td>9.241</td>
<td>2.55</td>
<td>0.28</td>
</tr>
<tr>
<td>BOS200708130</td>
<td>shiej002</td>
<td>BOS07</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>18</td>
<td>1.177</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>1.50</td>
<td>-1.67</td>
<td>1.74</td>
<td>1.88</td>
<td>1.60</td>
<td>8.862</td>
<td>3.02</td>
<td>0.34</td>
</tr>
<tr>
<td>DET200708080</td>
<td>shiej002</td>
<td>DET05</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>1.051</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>1.29</td>
<td>-0.71</td>
<td>2.70</td>
<td>2.92</td>
<td>2.77</td>
<td>9.260</td>
<td>2.65</td>
<td>0.29</td>
</tr>
<tr>
<td>TBA200708030</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>20</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>4.05</td>
<td>1.95</td>
<td>5.36</td>
<td>5.79</td>
<td>6.61</td>
<td>11.455</td>
<td>-0.13</td>
<td>-0.01</td>
</tr>
<tr>
<td>TBA200707280</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>15</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>5.40</td>
<td>-1.60</td>
<td>1.81</td>
<td>1.95</td>
<td>2.23</td>
<td>9.415</td>
<td>2.20</td>
<td>0.23</td>
</tr>
<tr>
<td>NYA200707220</td>
<td>shiej002</td>
<td>NYC16</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>10</td>
<td>1.070</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>27.00</td>
<td>6.90</td>
<td>10.31</td>
<td>11.14</td>
<td>10.41</td>
<td>12.081</td>
<td>-1.44</td>
<td>-0.12</td>
</tr>
<tr>
<td>TBA200707170</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>2.57</td>
<td>-0.14</td>
<td>3.27</td>
<td>3.53</td>
<td>4.03</td>
<td>9.994</td>
<td>1.74</td>
<td>0.17</td>
</tr>
<tr>
<td>TBA200707120</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>18</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>7.50</td>
<td>6.33</td>
<td>9.74</td>
<td>10.52</td>
<td>12.01</td>
<td>14.071</td>
<td>-3.51</td>
<td>-0.25</td>
</tr>
<tr>
<td>KCA200707060</td>
<td>shiej002</td>
<td>KAN06</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>23</td>
<td>1.033</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>4.70</td>
<td>-1.17</td>
<td>2.24</td>
<td>2.42</td>
<td>2.34</td>
<td>8.856</td>
<td>3.22</td>
<td>0.36</td>
</tr>
<tr>
<td>CLE200707010</td>
<td>shiej002</td>
<td>CLE08</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>19</td>
<td>1.132</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>2.84</td>
<td>-0.63</td>
<td>2.78</td>
<td>3.00</td>
<td>2.65</td>
<td>9.323</td>
<td>2.48</td>
<td>0.27</td>
</tr>
<tr>
<td>TBA200706260</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>6.43</td>
<td>0.57</td>
<td>3.98</td>
<td>4.30</td>
<td>4.91</td>
<td>10.505</td>
<td>1.10</td>
<td>0.10</td>
</tr>
<tr>
<td>ARI200706200</td>
<td>shiej002</td>
<td>PHO01</td>
<td>NL</td>
<td>TBA</td>
<td>2007</td>
<td>15</td>
<td>1.111</td>
<td>3.280</td>
<td>4.567</td>
<td>4.909</td>
<td>3.622</td>
<td>10.80</td>
<td>3.60</td>
<td>6.88</td>
<td>7.40</td>
<td>6.66</td>
<td>11.092</td>
<td>-0.23</td>
<td>-0.02</td>
</tr>
<tr>
<td>COL200706150</td>
<td>shiej002</td>
<td>DEN02</td>
<td>NL</td>
<td>TBA</td>
<td>2007</td>
<td>18</td>
<td>1.160</td>
<td>3.280</td>
<td>4.567</td>
<td>4.909</td>
<td>3.622</td>
<td>7.50</td>
<td>4.17</td>
<td>7.45</td>
<td>8.01</td>
<td>6.90</td>
<td>11.361</td>
<td>-0.42</td>
<td>-0.04</td>
</tr>
<tr>
<td>FLO200706090</td>
<td>shiej002</td>
<td>MIA01</td>
<td>NL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>1.068</td>
<td>3.280</td>
<td>4.567</td>
<td>4.909</td>
<td>3.622</td>
<td>2.57</td>
<td>0.14</td>
<td>3.42</td>
<td>3.68</td>
<td>3.44</td>
<td>9.508</td>
<td>2.03</td>
<td>0.21</td>
</tr>
<tr>
<td>TBA200706040</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>22</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>2.45</td>
<td>2.59</td>
<td>6.00</td>
<td>6.48</td>
<td>7.40</td>
<td>12.023</td>
<td>-0.73</td>
<td>-0.06</td>
</tr>
<tr>
<td>TBA200705300</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>27</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>3.00</td>
<td>-0.78</td>
<td>2.63</td>
<td>2.84</td>
<td>3.24</td>
<td>9.229</td>
<td>2.93</td>
<td>0.32</td>
</tr>
<tr>
<td>CHA200705250</td>
<td>shiej002</td>
<td>CHI12</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>1.084</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>5.14</td>
<td>3.43</td>
<td>6.84</td>
<td>7.39</td>
<td>6.82</td>
<td>11.619</td>
<td>-0.28</td>
<td>-0.02</td>
</tr>
<tr>
<td>TBA200705200</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>1.29</td>
<td>-1.00</td>
<td>2.41</td>
<td>2.60</td>
<td>2.97</td>
<td>9.375</td>
<td>2.50</td>
<td>0.27</td>
</tr>
<tr>
<td>TBA200705150</td>
<td>shiej002</td>
<td>LBV01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>24</td>
<td>1.257</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>3.38</td>
<td>0.38</td>
<td>3.79</td>
<td>4.09</td>
<td>3.26</td>
<td>9.391</td>
<td>2.61</td>
<td>0.28</td>
</tr>
<tr>
<td>BAL200705090</td>
<td>shiej002</td>
<td>BAL12</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>27</td>
<td>1.109</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>0.00</td>
<td>-0.56</td>
<td>2.85</td>
<td>3.08</td>
<td>2.78</td>
<td>8.879</td>
<td>3.35</td>
<td>0.38</td>
</tr>
<tr>
<td>TBA200705030</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>22</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>3.68</td>
<td>-0.95</td>
<td>2.46</td>
<td>2.66</td>
<td>3.03</td>
<td>9.354</td>
<td>2.57</td>
<td>0.27</td>
</tr>
<tr>
<td>OAK200704270</td>
<td>shiej002</td>
<td>OAK01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>24</td>
<td>0.833</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>1.12</td>
<td>-0.25</td>
<td>3.16</td>
<td>3.41</td>
<td>4.10</td>
<td>9.951</td>
<td>1.92</td>
<td>0.19</td>
</tr>
<tr>
<td>TBA200704220</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>24</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>2.25</td>
<td>-1.00</td>
<td>2.41</td>
<td>2.60</td>
<td>2.97</td>
<td>9.200</td>
<td>2.84</td>
<td>0.31</td>
</tr>
<tr>
<td>TBA200704160</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>19</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>7.11</td>
<td>3.47</td>
<td>6.88</td>
<td>7.43</td>
<td>8.48</td>
<td>12.402</td>
<td>-1.36</td>
<td>-0.11</td>
</tr>
<tr>
<td>TEX200704110</td>
<td>shiej002</td>
<td>ARL02</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>21</td>
<td>0.979</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>5.14</td>
<td>3.71</td>
<td>7.12</td>
<td>7.69</td>
<td>7.86</td>
<td>12.225</td>
<td>-1.03</td>
<td>-0.08</td>
</tr>
<tr>
<td>TBA200704060</td>
<td>shiej002</td>
<td>STP01</td>
<td>AL</td>
<td>TBA</td>
<td>2007</td>
<td>20</td>
<td>0.876</td>
<td>3.408</td>
<td>4.686</td>
<td>5.064</td>
<td>3.786</td>
<td>4.05</td>
<td>0.45</td>
<td>3.86</td>
<td>4.17</td>
<td>4.76</td>
<td>10.427</td>
<td>1.15</td>
<td>0.11</td>
</tr>
</table>
</div>
<p>To get Shields&#8217; WAR for the 2007 season, we can take a weighted average of his starts, using the following query:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;">mysql<span class="sy0">&gt;</span> <span class="kw1">SELECT</span> SUM<span class="br0">&#40;</span>WAR<span class="br0">&#41;</span> <span class="kw1">FROM</span> pitcher_game_start_fip <span class="kw1">WHERE</span> rs_player_id <span class="sy0">=</span> <span class="st0">&#8216;shiej002&#8242;</span> <span class="kw1">AND</span> year <span class="sy0">=</span> <span class="nu0">2007</span>;<br />
<span class="sy0">+</span><span class="co1">&#8212;&#8212;&#8212;-+</span><br />
<span class="sy0">|</span> SUM<span class="br0">&#40;</span>WAR<span class="br0">&#41;</span> <span class="sy0">|</span><br />
<span class="sy0">+</span><span class="co1">&#8212;&#8212;&#8212;-+</span><br />
<span class="sy0">|</span> &nbsp; &nbsp; 4<span class="sy0">.</span>74 <span class="sy0">|</span> <br />
<span class="sy0">+</span><span class="co1">&#8212;&#8212;&#8212;-+</span><br />
1 row <span class="kw1">IN</span> <span class="kw1">SET</span> <span class="br0">&#40;</span><span class="nu0">0.00</span> sec<span class="br0">&#41;</span></div>
</div>
<p>Alternatively, you could calculate the pitcher&#8217;s weighted park factor, weighted league ERA, and weighted league RA and use these values with the pitcher&#8217;s IP, HR, SO, BB, etc for the season.</p>
<p>Well, there you have it.  The next thing to do is to store season FIP&#8217;s, WAR&#8217;s and other values for more practical comparisons of players.  Then, I&#8217;ll have to calculate the WAR of relief pitchers, something <a href="http://www.beyondtheboxscore.com/2009/4/29/856308/bullpen-chaining-and-reliever-war">a bit more complicated</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2009/08/31/calculating-fip-and-war-from-retrosheet-data-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Off to Minny</title>
		<link>http://www.temporaldisruption.com/2009/08/28/off-to-minny/</link>
		<comments>http://www.temporaldisruption.com/2009/08/28/off-to-minny/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 16:10:14 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[FIP]]></category>
		<category><![CDATA[Metrodome]]></category>
		<category><![CDATA[Minnesota]]></category>
		<category><![CDATA[WAR]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=41</guid>
		<description><![CDATA[Going to Minnesota for a short weekend trip. Hopefully I&#8217;ll run into a few of those 10,000 lakes, but I doubt I&#8217;ll see much more than that ugly, green carpet covered by a big, white balloon. Made a lot of progress on my FIP and WAR calculations last night &#8230; almost ready to show some [...]]]></description>
			<content:encoded><![CDATA[<p>Going to Minnesota for a short weekend trip.  Hopefully I&#8217;ll run into a few of those 10,000 lakes, but I doubt I&#8217;ll see much more than that <a href="http://en.wikipedia.org/wiki/Metrodome">ugly, green carpet covered by a big, white balloon</a>.</p>
<p>Made a lot of progress on <a href="http://www.bryanpackman.com/blog/2009/08/27/park-factors/">my FIP and WAR calculations</a> last night &#8230; almost ready to show some results.  I&#8217;ll have a post detailing the process when I get back.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2009/08/28/off-to-minny/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Park Factors</title>
		<link>http://www.temporaldisruption.com/2009/08/27/park-factors/</link>
		<comments>http://www.temporaldisruption.com/2009/08/27/park-factors/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 16:01:13 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[A.J. Burnett]]></category>
		<category><![CDATA[Amazon SQS]]></category>
		<category><![CDATA[C.C. Sabathia]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[FIP]]></category>
		<category><![CDATA[park factor]]></category>
		<category><![CDATA[retrosheet]]></category>
		<category><![CDATA[sabermetrics]]></category>
		<category><![CDATA[WAR]]></category>

		<guid isPermaLink="false">http://www.temporaldisruption.com/?p=29</guid>
		<description><![CDATA[Oh, it feels good to be back. Yesterday, I spent a full day at the office programming, and then programmed for a few more hours once I got home. After feeling &#8220;stuck&#8221; at a job I stopped liking, it&#8217;s been a while since I&#8217;ve felt that passion for something I was working on. It feels [...]]]></description>
			<content:encoded><![CDATA[<p>Oh, it feels good to be back.  Yesterday, I spent a full day at the office programming, and then programmed for a few more hours once I got home.  After <a href="http://www.bryanpackman.com/blog/2009/08/18/just-another-wordpress-weblog/">feeling &#8220;stuck&#8221; at a job</a> I stopped liking, it&#8217;s been a while since I&#8217;ve felt that passion for something I was working on.  It feels good to want to continue my work into the wee hours of the night.</p>
<p>What was I working on?  Calculating <a href="http://en.wikipedia.org/wiki/Batting_park_factor">park factors</a> from <a href="http://retrosheet.org/">retrosheet</a> files.  I spent the last day and a half coming up with a scheme to update park factors with each run that is scored.</p>
<p>Retrosheet files deal with completed games from past seasons, so one doesn&#8217;t necessarily have to update park factors with each event.  Alternatively, you could parse the events from these logs, and then calculate the park factors of each stadium after completing the parsing of a full season&#8217;s worth of event files.  Of course, this would be a faster and easier method, but &#8230;</p>
<p>I plan on turning this application into something more than just a database derived from retrosheet files.  At some point, I hope to be gathering stats from a live feed, or generating my own.  When this day comes, I not only want to insert these events into a database in real time, I want to update various advanced metrics in &#8220;real time&#8221; as well.</p>
<p>Clearly, this is no small task.  Take, for example, <a href="http://www.beyondtheboxscore.com/2009/6/20/919602/war-lords-of-the-diamond-pitchers">FIP-based pitching WAR</a>.  Suppose C.C. Sabathia is pitching in Yankee Stadium.  Obviously, the events in this game are going to affect the ERA, FIP, and WAR of Sabathia and affect the park factor of Yankee Stadium.  But the change in Yankee Stadium&#8217;s park factor also affects A.J. Burnett&#8217;s WAR because he too pitches at &#8220;The Stadium&#8221; (btw, I am not a Yankee fan, this is just an example).  These events also change the league averages for the AL, which affect the WAR of every pitcher in the AL.</p>
<p>The less complicated way to handle this would be to have a cron run after every game is completed that will recalculate the league averages and park factors as well as the ERA, FIP, and WAR of every pitcher.  But c&#8217;mon!  This is 2009 &#8211; people want things in &#8220;real time&#8221;.</p>
<p>I don&#8217;t know what the solution is yet &#8230; I&#8217;m thinking something involving <a href="http://aws.amazon.com/sqs/">Amazon&#8217;s Simple Queue Service</a>.  Whatever the solution is, if it&#8217;s even feasible, I&#8217;m sure it&#8217;ll be fun trying to get there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2009/08/27/park-factors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weird Things about ERA</title>
		<link>http://www.temporaldisruption.com/2009/08/21/weird-things-about-era/</link>
		<comments>http://www.temporaldisruption.com/2009/08/21/weird-things-about-era/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 23:19:46 +0000</pubDate>
		<dc:creator>Bryan Packman</dc:creator>
				<category><![CDATA[Baseball]]></category>
		<category><![CDATA[ERA]]></category>
		<category><![CDATA[fielder's choice]]></category>
		<category><![CDATA[FIP]]></category>
		<category><![CDATA[retrosheet]]></category>
		<category><![CDATA[sabermetrics]]></category>
		<category><![CDATA[WAR]]></category>

		<guid isPermaLink="false">http://experiweb.com/?p=16</guid>
		<description><![CDATA[One of my planned projects during my new found unemployment involves sabermetrics. As a first step, I&#8217;m writing scripts to parse Retrosheet files and calculate advanced pitching metrics like FIP and WAR. Along with these advanced metrics, I&#8217;m also calculating more traditional stats like ERA. When some of the resulting ERAs in my database did [...]]]></description>
			<content:encoded><![CDATA[<p>One of my planned projects during my new found unemployment involves <a href="http://en.wikipedia.org/wiki/Sabermetrics">sabermetrics</a>.  As a first step, I&#8217;m writing scripts to parse <a href="http://retrosheet.org/">Retrosheet files</a> and calculate advanced pitching metrics like <a href="http://www.ehow.com/how_2288361_calculate-fip-statistic.html">FIP</a> and <a href="http://www.insidethebook.com/ee/index.php/site/article/how_to_calculate_war/">WAR</a>.  Along with these advanced metrics, I&#8217;m also calculating more traditional stats like ERA.</p>
<p>When some of the resulting ERAs in my database did not match those found on the back of a player&#8217;s baseball card, I did a bit of debugging and found out that some weird shit happens with plays involving a fielder&#8217;s choice.  For example take this <a href="http://sports.yahoo.com/mlb/boxscore?gid=270506103&#038;page=plays">game between the White Sox and Angels on May 6, 2007</a>.  The top of the 8th inning starts with Bartolo Colon on the mound for the Angels.  Here&#8217;s the play-by-play for that half inning:</p>
<blockquote><p>
- C. Kotchman at first<br />
- J. Crede doubled to deep center<br />
- A. Cintron singled to right, J. Crede to third<br />
- S. Shields relieved B. Colon<br />
- R. Sweeney grounded into fielder&#8217;s choice, J. Crede scored, A. Cintron out at second<br />
- A.J. Pierzynski hit for G. Molina<br />
- A.J. Pierzynski homered to deep right, R. Sweeney scored<br />
- D. Erstad popped out to shallow left<br />
- P. Ozuna flied out to right
</p></blockquote>
<p>Colon put Crede and Cintron on base (that&#8217;s a lot of players whose last names begin with the letter &#8216;C&#8217;).  Shields then relieved Colon and finished the inning.  Crede, Cintron, and Pierzynski all scored in the inning.  I was under the assumption that Colon would&#8217;ve been responsible for Crede and Cintron, and Shields would&#8217;ve been responsible for Pierzynski.  Turns out that all runs are charged to Colon.  Well, according to <a href="http://www.mlb.com/mlb/official_info/official_rules/official_scorer_10.jsp">rule 10.16(g)</a>:</p>
<blockquote><p>
When pitchers are changed during an inning, the official scorer shall not charge the relief pitcher with any run (earned or unearned) scored by a runner who was on base at the time such relief pitcher entered the game, <strong>nor for runs scored by any runner who reaches base on a fielder&#8217;s choice that puts out a runner left on base by any preceding pitcher.</strong>
</p></blockquote>
<p>The official rules go on to give examples using fictitious players with names like Peter, Roger, Abel, Baker, and Charlie.</p>
<p>Anyway, I had to transfer base runner responsibilities between pitchers during such situations to compensate.  I&#8217;ll provide details of the solution after cleaning up the code a bit.  A lot of help was provided by looking through <a href="http://chadwick.sourceforge.net/">Chadwick</a>, an open source suite of tools for parsing Retrosheet files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.temporaldisruption.com/2009/08/21/weird-things-about-era/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
