{"id":254,"date":"2018-03-29T14:49:35","date_gmt":"2018-03-29T21:49:35","guid":{"rendered":"http:\/\/www.ootp.cavebutter.net\/blog\/?p=254"},"modified":"2018-03-29T14:49:35","modified_gmt":"2018-03-29T21:49:35","slug":"pitching-stats-6-era","status":"publish","type":"post","link":"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/254","title":{"rendered":"Pitching Stats 6: ERA+"},"content":{"rendered":"<p>This one may prove to be tricky, if only because there are a couple of ways to calculate it. \u00a0Baseball-Reference says they calculate it one way, Wikipedia says that bb-ref used to calculate it that way, but then they changed. \u00a0So, we may see some variation here. \u00a0Frankly, I&#8217;m not even sure why I&#8217;d want to use this counter-intuitive + stat anyway. \u00a0However, it&#8217;s in the game, and I&#8217;d like to be able to use it as a sanity check if nothing else.<\/p>\n<p>Here&#8217;s the first way I am going to try it. \u00a0Defined by Wikipedia as the way bb-ref currently does the calculation:<\/p>\n<p><code>ERA+ = 100 * (2 - (ERA\/lgERA) * 1\/ParkFactor)<\/code><\/p>\n<p>No additional joins are needed for this, so we can just plug it in. \u00a0Let&#8217;s do it and check our results.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v1.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"255\" data-permalink=\"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/254\/eraplus-v1\" data-orig-file=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v1.jpg?fit=666%2C551\" data-orig-size=\"666,551\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ERAplus v1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v1.jpg?fit=666%2C551\" class=\"aligncenter size-full wp-image-255\" src=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v1.jpg?resize=666%2C551\" alt=\"\" width=\"666\" height=\"551\" srcset=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v1.jpg?w=666 666w, https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v1.jpg?resize=300%2C248 300w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/a>Awful. \u00a0Just awful. \u00a01\/3 of the result set was hugely off, and only about half was within 5 percent.<\/p>\n<p>We&#8217;ll try the original recipe for this stat and see if we get better luck. \u00a0That one is:<\/p>\n<p><code>ERA+ = 100 * (lgERA\/ERA) * ParkFactor<\/code><\/p>\n<p>And the results:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v2.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"256\" data-permalink=\"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/254\/eraplus-v2\" data-orig-file=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v2.jpg?fit=687%2C549\" data-orig-size=\"687,549\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ERAplus v2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v2.jpg?fit=687%2C549\" class=\"aligncenter size-full wp-image-256\" src=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v2.jpg?resize=687%2C549\" alt=\"\" width=\"687\" height=\"549\" srcset=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v2.jpg?w=687 687w, https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/ERAplus-v2.jpg?resize=300%2C240 300w\" sizes=\"auto, (max-width: 687px) 100vw, 687px\" \/><\/a>Much, much better. \u00a024 within 5 points and only 1 more than 10. \u00a0And that one is also one that was way off on the first try. \u00a0I am good to keep this version and even to use it for evaluative purposes. \u00a0I think the difference between this and the game is probably down to park factors. \u00a0Here&#8217;s the CalcPitching table to this point:<\/p>\n<pre class=\"line-numbers\"><code class=\"language-sql\">DROP TABLE IF EXISTS CalcPitching;\r\nCREATE TABLE IF NOT EXISTS CalcPitching AS\r\n\r\nSELECT\r\n    i.player_id\r\n    , i.year\r\n    , i.stint\r\n    , i.team_id\r\n    , i.league_id\r\n    , r.sub_league_id\r\n    , split_id\r\n    , i.ip\r\n    , i.ab\r\n    , i.tb\r\n    , i.ha\r\n    , i.k\r\n    , i.bf\r\n    , i.rs\r\n    , i.bb\r\n    , i.r\r\n    , i.er\r\n    , i.gb\r\n    , i.fb\r\n    , i.pi\r\n    , i.ipf\r\n    , i.g\r\n    , i.gs\r\n    , i.w\r\n    , i.l\r\n    , i.s\r\n    , i.sa\r\n    , i.da\r\n    , i.sh\r\n    , i.sf\r\n    , i.ta\r\n    , i.hra\r\n    , i.bk\r\n    , i.ci\r\n    , i.iw\r\n    , i.wp\r\n    , i.hp\r\n    , i.gf\r\n    , i.dp\r\n    , i.qs\r\n    , i.svo\r\n    , i.bs\r\n    , i.ra\r\n    , i.cg\r\n    , i.sho\r\n    , i.sb\r\n    , i.cs\r\n    , i.hld\r\n    , i.ir\r\n    , i.irs\r\n    , i.wpa\r\n    , i.li\r\n    , i.outs\r\n    , i.war\r\n    , @InnPitch := ((3*ip)+ipf)\/3 AS InnPitch\r\n    , round((9*i.k)\/@InnPitch,1) AS 'k9'\r\n    , round((9*i.bb)\/@InnPitch,1) AS 'bb9'\r\n    , round((9*i.hra)\/@InnPitch,1) AS 'HR9'\r\n    , round((i.bb+i.ha)\/@InnPitch,2) AS WHIP\r\n    , round(i.k\/i.bb,2) AS 'K\/BB'\r\n    , i.gb\/i.fb AS 'gb\/fb'\r\n    , round((i.ha-i.hra)\/(i.ab-i.k-i.hra-i.sh+i.sf),3) AS BABIP\r\n    , @ERA := round((i.er\/@InnPitch)*9,2) AS ERA\r\n    , round(((13*i.hra)+(3*(i.bb+i.hp))-(2*i.k))\/@InnPitch+f.FIPConstant,2) AS FIP \r\n    , round(((13*(i.fb*f.hr_fb_pct))+(3*(i.bb+i.hp))-(2*i.k))\/@InnPitch+f.FIPConstant,2) AS xFIP\r\n    , round(100*((@ERA + (@ERA - @ERA*(p.avg)))\/slg.slgERA),0) AS ERAminus\r\n    , round(100*(slg.slgERA\/@ERA)*p.avg,0) AS ERAplus\r\n    \r\n    FROM players_career_pitching_stats AS i\r\n    INNER JOIN team_relations AS r ON i.team_id=r.team_id AND i.league_id=r.league_id\r\n    INNER JOIN FIPConstant AS f ON i.year=f.year AND i.league_id=f.league_id\r\n    INNER JOIN sub_league_history_pitching AS slg ON i.year=slg.year AND i.league_id=slg.league_id AND r.sub_league_id=slg.sub_league_id\r\n    INNER JOIN teams AS t ON i.team_id=t.team_id\r\n    INNER JOIN parks AS p ON t.park_id=p.park_id\r\nWHERE i.split_id=1 AND i.league_id&lt;&gt;0;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This one may prove to be tricky, if only because there are a couple of ways to calculate it. \u00a0Baseball-Reference says they calculate it one way, Wikipedia says that bb-ref used to calculate it that way, but then they changed. \u00a0So, we may see some variation here. \u00a0Frankly, I&#8217;m not even sure why I&#8217;d want&hellip; <a class=\"more-link\" href=\"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/254\">Continue reading <span class=\"screen-reader-text\">Pitching Stats 6: ERA+<\/span> <span class=\"meta-nav\" aria-hidden=\"true\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[29],"tags":[7,4,15],"class_list":["post-254","post","type-post","status-publish","format-standard","hentry","category-pitching","tag-mysql","tag-ootp","tag-pitching"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9cxb5-46","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/comments?post=254"}],"version-history":[{"count":1,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/254\/revisions"}],"predecessor-version":[{"id":257,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/254\/revisions\/257"}],"wp:attachment":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/media?parent=254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/categories?post=254"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/tags?post=254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}