{"id":261,"date":"2018-03-30T10:13:56","date_gmt":"2018-03-30T17:13:56","guid":{"rendered":"http:\/\/www.ootp.cavebutter.net\/blog\/?p=261"},"modified":"2018-03-30T10:16:30","modified_gmt":"2018-03-30T17:16:30","slug":"pitching-stats-7-fip","status":"publish","type":"post","link":"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/261","title":{"rendered":"Pitching Stats 7: FIP-"},"content":{"rendered":"<p>FIP- does for FIP just what ERA- does for ERA: it scales it to 100 and accounts for park factors and league run environment. \u00a0I am still searching for a definitive formula- but I know that to begin with, I will need to calculate the league FIP for comparison purposes. \u00a0I&#8217;ll go back and adjust the sub-league-pitching-stats table to include it.<\/p>\n<p>In fact, I am going one step further, and generating a FIP for each sub-league. \u00a0I am guessing that this will cause me to deviate a bit from the game&#8217;s generated scores, but in this case, I think this will lead me to more accurate results.<\/p>\n<p>The revised sub-league-pitching-stats table now looks like this:<\/p>\n<pre class=\"line-numbers\"><code class=\"language-sql\">DROP TABLE IF EXISTS sub_league_history_pitching;\r\nCREATE TABLE IF NOT EXISTS sub_league_history_pitching AS\r\n\r\nSELECT\r\n       year\r\n     , league_id\r\n     , sub_league_id\r\n     , round((totER\/totIP)*9,2) AS slgERA \r\n     , round((adjHRA + adjBB + adjHP - adjK)\/totIP+FIPConstant,2) AS slgFIP\r\n     #FIP = ((13*HR)+(3*(BB+HBP))-(2*K))\/IP + constant\r\nFROM  (        \r\n     SELECT p.year\r\n          , p.league_id\r\n          , t.sub_league_id\r\n          , ((sum(ip)*3)+sum(ipf))\/3 AS totIP\r\n          , sum(er) AS totER\r\n          , 13*sum(hra) AS adjHRA\r\n          , 3*sum(bb) AS adjBB\r\n          , 3*sum(hp) AS adjHP\r\n          , 2*sum(k) AS adjK\r\n          , f.FIPConstant\r\n     FROM CalcPitching AS p INNER JOIN team_relations AS t ON p.team_id=t.team_id\r\n          INNER JOIN FIPConstant AS f ON p.year=f.year AND p.league_id=f.league_id\r\n     GROUP BY year, league_id, sub_league_id\r\n      ) AS x ;<\/code><\/pre>\n<p>The calculation for FIP- is exactly the same as ERA-:<\/p>\n<p><code>FIP Minus = 100*((FIP + (FIP \u2013 FIP*(PF\/100)) )\/ AL or NL FIP)<\/code><\/p>\n<p>We&#8217;ve already got all of the data points we need, so let&#8217;s plug it in and see what happens.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/Fip-v1.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"263\" data-permalink=\"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/261\/fip-v1-2\" data-orig-file=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/Fip-v1.jpg?fit=574%2C551\" data-orig-size=\"574,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=\"Fip- v1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/Fip-v1.jpg?fit=300%2C288\" data-large-file=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/Fip-v1.jpg?fit=574%2C551\" class=\"aligncenter size-full wp-image-263\" src=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/Fip-v1.jpg?resize=574%2C551\" alt=\"\" width=\"574\" height=\"551\" srcset=\"https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/Fip-v1.jpg?w=574 574w, https:\/\/i0.wp.com\/www.ootp.cavebutter.net\/blog\/wp-content\/uploads\/2018\/03\/Fip-v1.jpg?resize=300%2C288 300w\" sizes=\"auto, (max-width: 574px) 100vw, 574px\" \/><\/a><\/p>\n<p>Pretty good. 25 of 30 within 5 points. \u00a0Two that were ridiculously off and 3 that are meh. \u00a0I can rely on this stat to be game equivalent 85% of the time; in the right ballpark 93% of the time; so ridiculously off that I will be able to spot it immediately 6% of the time. \u00a0I wouldn&#8217;t want my real life money riding on this, maybe, but it&#8217;s good enough for video games.<\/p>\n<p>The script for CalcPitching table is now:<\/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    , @FIP := 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    , round(100*((@FIP + (@FIP - @FIP*(p.avg)))\/slg.slgFIP),0) AS FIPminus\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>FIP- does for FIP just what ERA- does for ERA: it scales it to 100 and accounts for park factors and league run environment. \u00a0I am still searching for a definitive formula- but I know that to begin with, I will need to calculate the league FIP for comparison purposes. \u00a0I&#8217;ll go back and adjust&hellip; <a class=\"more-link\" href=\"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/261\">Continue reading <span class=\"screen-reader-text\">Pitching Stats 7: FIP-<\/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_post_was_ever_published":false,"_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}},"categories":[29],"tags":[7,4,15],"class_list":["post-261","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-4d","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/261","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=261"}],"version-history":[{"count":3,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":265,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/261\/revisions\/265"}],"wp:attachment":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}