<<

Package ‘’ January 26, 2016 Type Package Title Sabermetrics Functions for Version 2.0 Date 2016-01-25 Author Peter Xenopoulos, Fernando Crema Maintainer Peter Xenopoulos Description A collection of baseball analytics functions for sabermetrics purposes. Among these functions include popular metrics such as FIP, wOBA, and and other . License GPL-3 Imports XML NeedsCompilation no Repository CRAN Date/Publication 2016-01-26 14:14:00

R topics documented:

sabermetrics-package ...... 2 babip ...... 3 dice ...... 4 era...... 5 eraminus ...... 6 fip...... 7 fipminus ...... 8 fp ...... 10 handedparkfactors ...... 11 iso...... 12 lgwSB ...... 13 linearWeights ...... 14 ...... 16 obp ...... 17 ops...... 18

1 2 sabermetrics-package

opsplus ...... 19 parkfactors ...... 20 pyth...... 22 raweqa ...... 23 secavg ...... 24 slg...... 25 whip...... 26 ...... 27 wraa...... 29 wrc ...... 30 wrcplus ...... 31 wsb ...... 33 xfip ...... 34 xfipminus ...... 35

Index 37

sabermetrics-package Sabermetrics Functions For Baseball Analytics

Description A collection of baseball analytics functions for sabermetrics purposes. Among these functions include popular metrics such as wOBA, runs created functions as well as enhanced pitching metrics.

Details

Package: Sabermetrics Type: Package Version: 2.0 Date: 2016-01-25 License: GPL-3

Author(s)

Peter Xenopoulos, Fernando Crema

References

Wikipedia: http://en.wikipedia.org/wiki/Sabermetrics#Examples | Reddit: http://www.reddit.com/r/Sabermetrics | Peter Xenopoulos Website: www.peterxeno.com babip 3

babip Average on Balls in Play (BABIP)

Description BABIP is a statistic which measures how often a non-home batted ball falls for a .

Usage babip(h, hr, ab, k, sf)

Arguments h Hits hr Home Runs ab At Bats k sf Sacrifice Flies

Value Returns a numerical value equal to (h-hr)/(ab-hr-k-sf)

Author(s) Fernando Crema, Peter Xenopoulos

References http://www.fangraphs.com/library/pitching/babip/

See Also obp,ops

Examples ## Let's Calculate 's BABIP for the 2014 season ## He had 173 Hits, 36 HR's, 602 AB's, 184 K's, and 10 SF's ## We should get .368 as our output babip(173,36,602,184,10)

## The function is currently defined as function (h, hr, ab, k, sf) { babip <- (h-hr)/(ab-hr-k-sf) return(babip) } 4 dice

dice Defense-Independent Component ERA

Description DICE represents a way to measure a ’s performance on the ERA scale using only events a pitcher can "control"

Usage dice(hr, bb, hbp, k, ip)

Arguments hr Home Runs bb Walks hbp Hit By Pitches k Strikeouts ip Pitched

Details DICE uses the typical ERA scale.

Value Returns a value equal to (13*hr+3*bb+3*hbp-2*k)/ip + 3.0

Note (IP) is commonly reported with .1 indicating 1/3 of an and .2 indicating 2/3 of an inning. In order for this function to be accurate, please change the decimal to .333 for 1/3 of an inning and .666 for 2/3 of an inning.

Author(s) Peter Xenopoulos

References https://en.wikipedia.org/wiki/Defense-Independent_Component_ERA

See Also era,fip,xfip,whip era 5

Examples

## The function is currently defined as function (hr, bb, hbp, k, ip) { dice = (13 * hr + 3 * bb + 3 * hbp - 2 * k)/ip + 3 return(dice) }

era Earned- (ERA)

Description ERA is a basic metric used to describe a ability to prevent runs.

Usage era(er, ip)

Arguments er Earned Runs ip Innings Pitched

Details ERA is not a perfect indicator of pitcher skill. It is highly defense dependent.

Value Returns a numerical value equal to (9*er)/ip

Note Innings Pitched (IP) is commonly reported with .1 indicating 1/3 of an inning and .2 indicating 2/3 of an inning. In order for this function to be accurate, please change the decimal to .333 for 1/3 of an inning and .666 for 2/3 of an inning.

Author(s) Fernando Crema, Peter Xenopoulos

References http://www.fangraphs.com/library/pitching/era/ 6 eraminus

See Also whip,fip,xfip

Examples ## Let's calculate 's ERA for the 2014 Season ## He had 39 ER's and 198.333 IP ## We should get an ERA = to 1.77 era(39,198.333)

## The function is currently defined as function (er, ip) { era <- (9 * er)/ip return(era) }

eraminus ERA-

Description ERA- is a park-adjusted version of ERA

Usage eraminus(ERA, ParkFactor, LeagueERA)

Arguments ERA Player ERA ParkFactor Park Factor LeagueERA League Average ERA

Details League Average is set to 100 each season. Each point below or above 100 is one percentage point better or worse than league average.

Value Returns a value equal to (ERA+(ERA-(ERA*(ParkFactor/100))))/(LeagueERA)*100

Note Park Factors can be found in the references section fip 7

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/library/pitching/era-fip-xfip/ http://www.fangraphs.com/guts.aspx?type=pf&teamid=0&season=2014

See Also era,fipminus,xfipminus

Examples ## The function is currently defined as function (ERA, ParkFactor, LeagueERA) { eraminus <- (ERA + (ERA - (ERA * (ParkFactor/100))))/(LeagueERA) * 100 return(eraminus) }

fip Field Independent Pitching (FIP)

Description FIP is a statistic that measure a pitcher’s performance independent of defense. FIP uses outcomes that do not take into account a team’s defense.

Usage fip(HR, BB, HBP, K, IP, year)

Arguments HR Homeruns given up BB Walks given up HBP Hit by pitches given up K Strikeouts IP Innings Pitched year Season

Details While FIP is not a complete representation of a pitcher’s performance, it is regarded as a better representation of performance than ERA. 8 fipminus

Value Returns a numerical vector equal to ((13*HR)+(3*(BB+HBP))-(2*K))/IP + constant Constant = Season FIP Constant

Note Innings Pitched (IP) is commonly reported with .1 indicating 1/3 of an inning and .2 indicating 2/3 of an inning. In order for this function to be accurate, please change the decimal to .333 for 1/3 of an inning and .666 for 2/3 of an inning.

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/library/pitching/fip/

See Also era, whip, xfip, fipminus

Examples ## Let's calculate Clayton Kershaw's 2014 FIP ## He had 9 HR's, 31 BB's, 2 HBP's, 239 K's, and 198.333 IP's ## We should get 1.81 as our output fip(9,31,2,239,198.333,2014)

## The function is currently defined as function (HR, BB, HBP, K, IP, year) { constant <- weights$cFIP[which(weights$Season == year)] fip <- ((13 * HR) + (3 * (BB + HBP)) - (2 * K))/IP + constant return(fip) }

fipminus FIP-

Description FIP- is a park-adjusted version of FIP

Usage fipminus(FIP, ParkFactor, LeagueFIP) fipminus 9

Arguments

FIP Player FIP ParkFactor Park Factor LeagueFIP League Average FIP

Details

League Average is set to 100 each season. Each point below or above 100 is one percentage point better or worse than league average.

Value

Returns a value equal to (FIP+(FIP-(FIP*(ParkFactor/100))))/(LeagueFIP)*100

Note

Park Factors can be found in the references section

Author(s)

Peter Xenopoulos

References

http://www.fangraphs.com/library/pitching/era-fip-xfip/ http://www.fangraphs.com/guts.aspx?type=pf&teamid=0&season=2014

See Also

fip,eraminus,xfipminus

Examples

## The function is currently defined as function (FIP, ParkFactor, LeagueFIP) { fipminus <- (FIP + (FIP - (FIP * (ParkFactor/100))))/(LeagueFIP) * 100 return(fipminus) } 10 fp

fp

Description

A measure that reflects the percentage of times a player successfully handles a batted or thrown ball.

Usage

fp(po, a, e)

Arguments

po a Assists e Errors

Details

Fielding percentage is not a particularly sought after defensive metric, especially with the advent of more comprehensive metrics such as UZR and DRS.

Value

Returns a value equal to (po+a)/(po+a+e)

Note

Fielding percentage is misleading in the fact that it does not account for a player’s range – that is, if a player that cannot get to a ball gives up a hit instead of having an opportunity to make an or .

Author(s)

Fernando Crema, Peter Xenopoulos

References

https://en.wikipedia.org/wiki/Fielding_percentage handedparkfactors 11

Examples ## Let's calculate Mike Trout's fielding percentage for 2014 ## He had PO = 383, A = 4, E = 3 ## We should get an output of .992 fp(383,4,3)

## The function is currently defined as function (po, a, e) { fp <- (po + a)/(po + a + e) return(fp) }

handedparkfactors Park Factors with Handedness

Description Returns hitting park factors based on handedness

Usage handedparkfactors(year, team)

Arguments year Season team Team

Details 0 = All Teams 1 = 2 = Orioles 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = Seattle Mariners 12 = Tampa Bay Rays 13 = 14 = 15 = Arizona Diamondbacks 12 iso

16 = 17 = 18 = Cincinnati Reds 19 = 20 = Florida Marlins 21 = 22 = 23 = 24 = Washington Nationals 25 = 26 = 27 = 28 = St. Louis Cardinals 29 = San Diego Padres 30 =

Value Returns a dataframe with park factors

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/guts.aspx?type=pfh&teamid=0&season=2014

See Also parkfactors

Examples

## To get all of 2014 Park Factors # handedparkfactors(2014)

## To get all of the Angels' Park Factors # handedparkfactors(2014,1)

iso

Description Isolated power measures a hitter’s ability to hit for extra bases. lgwSB 13

Usage iso(slg, avg)

Arguments slg avg

Value Returns a numerical value equal to SLG-AVG

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/library/offense/iso/

See Also opsplus, ops

Examples ## Let's calculate Mike Trout's isolated power in 2014 ## He had a SLG = .561 and an AVG = .287 ## We should get .274 iso(.561,.287)

## The function is currently defined as function (slg, avg) { iso <- slg - avg return(iso) }

lgwSB League wSB

Description This function helps find the League wSB

Usage lgwSB(year, SB, CS, , bb, hbp, ibb) 14 linearWeights

Arguments year Season SB League Stolen Bases CS League single Singles bb Walks hbp Hit By Pitches ibb Intentional Walks

Value Returns a value equal to (SB * runSB + CS * runCS) / (single + bb + hbp - ibb)

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/library/offense/wsb/

See Also wsb

Examples ## The function is currently defined as function (year, SB, CS, single, bb, hbp, ibb) { runSB <- linearWeights$runSB[which(linearWeights$Season == year)] runCS <- linearWeights$runCS[which(linearWeights$Season == year)] lgwSB <- (SB * runSB + CS * runCS)/(single + bb + hbp - ibb) }

linearWeights Linear Weights Dataset

Description This is a dataset containing useful yearly metrics from FanGraphs.

Usage linearWeights linearWeights 15

Format

A data frame with seasonal data going back to 1871. Contains 14 variables.

Season 1871-Present wOBA Season Average wOBA wOBAScale Season wOBA Scaling Factor wBB Weight of an walk wHBP Weight of a w1B Weight of a single w2B Weight of a w3B Weight of a wHR Weight of a runSB Weight of a runCS Weight of being caught stealing RPerPA Runs Per RPerW Runs Per Win cFIP Season FIP constant

Details

This dataset is useful for calculating season-dependent metrics such as wOBA and FIP.

Source

http://www.fangraphs.com/guts.aspx?type=cn

References

http://www.fangraphs.com/

Examples

## Give the last 5 years head(linearWeights, 5) 16 log5

log5 Log5

Description Log5 is a way to estimate the probability that Team A will win a game given the true winning probabilities of Team A and Team B

Usage log5(pA, pB, order = 0)

Arguments pA Probability that A wins pB Probability that B wins order 0 = A over B and 1 = B over A

Value Returns a value equal to (pA-pA*pB)/(pA+pB-2*pA*pB)

Author(s) Fernando Crema, Peter Xenopoulos

References https://en.wikipedia.org/wiki/Log5

See Also pyth

Examples ## Let's assume team A has a .60 true probability of winning ## Let's assume team B has a .40 true probability of winning ## We should get an output of 0.6923 log5(.60,.40)

## The function is currently defined as function (pA, pB, order = 0) { if (order) { aux = pB pB = pA pA = aux obp 17

} log5 <- (pA - pA * pB)/(pA + pB - 2 * pA * pB) return(log5) }

obp On-Base Percentage

Description

The OBP function calculates how often a player gets on base.

Usage

obp(H, BB, HBP, AB, SF)

Arguments

H Number of Hits BB Number of bases on balls (walks) HBP Number of hit by pitches AB Number of at bats SF Number of sacrifice flies

Value

Returns a numerical value equal to ((H+BB+HBP)/(AB+BB+SF+HBP))

Author(s)

Peter Xenopoulos

References

https://en.wikipedia.org/wiki/On-base_percentage

See Also

ops 18 ops

Examples

## Let's calculate Mike Trout's OBP for the 2014 season ## He had 173 hits, 83 bases on balls, 10 hit by pitches, 602 at bats, and 10 sacrifice flies ## We should get 0.377 as our output obp(173,83,10,602,10)

## The function is currently defined as function (H, BB, HBP, AB, SF) { onbase <- ((H + BB + HBP)/(AB + BB + SF + HBP)) return(onbase) }

ops On-Base Plus Slugging

Description

A metric that protrays a hitter’s ability to get on base and to hit for power.

Usage ops(slg, obp)

Arguments

slg Slugging Percentage obp On-Base Percentage

Value

Returns a numerical value equal to (OBP)+(SLG)

Author(s)

Peter Xenopoulos

References

http://www.fangraphs.com/library/offense/ops/ https://en.wikipedia.org/wiki/On-base_plus_slugging

See Also

opsplus, obp opsplus 19

Examples ## Let's calculate Mike Trout's OPS for the 2014 season ## He had an OBP = .377 and a SLG = .561 ## We should get .938 as our output ops(.561,.377)

## The function is currently defined as function (slg, obp) { ops <- slg + obp return(ops) }

opsplus OPS+

Description A useful metric to describe a hitter’s ability in terms of the league.

Usage opsplus(obp, slg, lgOBP, lgSLG)

Arguments obp On-base percentage slg Slugging percentage lgOBP League OBP lgSLG League Slugging Percentage

Value Returns a numerical value equal to ((obp/lgOBP)+(slg/lgSLG)-1)*100 100 = League Average 90 = 10 percent BELOW League Average 110 = 10 percent ABOVE League Average

Author(s) Peter Xenopoulos

References http://sports.yahoo.com/mlb/blog/big_league_stew/post/Everything-you-always-wanted-to-know-about- OPS-?urn=mlb,204667 http://www.fangraphs.com/library/offense/ops/ 20 parkfactors

See Also ops, slg, obp

Examples ## Let's calculate Mike Trout's 2014 OPS+ ## He had an OBP = .377 and a SLG = .561 ## League OBP = .316 and League SLG = .404 ## We should get 158.1652 as our output opsplus(.377,.561,.316,.404)

## The function is currently defined as function (obp, slg, lgOBP, lgSLG) { opsplus <- ((obp/lgOBP) + (slg/lgSLG) - 1) * 100 return(opsplus) }

parkfactors Park Factors

Description A function used to generate the park factors for a given season/team

Usage parkfactors(year, team)

Arguments year Season team Team

Details 0 = All Teams 1 = Los Angeles Angels 2 = Orioles 3 = Boston Red Sox 4 = Chicago White Sox 5 = Cleveland Indians 6 = Detroit Tigers 7 = Kansas City Royals 8 = Minnesota Twins 9 = New York Yankees 10 = Oakland Athletics 11 = Seattle Mariners parkfactors 21

12 = Tampa Bay Rays 13 = Texas Rangers 14 = Toronto Blue Jays 15 = Arizona Diamondbacks 16 = Atlanta Braves 17 = Chicago Cubs 18 = Cincinnati Reds 19 = Colorado Rockies 20 = Florida Marlins 21 = Houston Astros 22 = Los Angeles Dodgers 23 = Milwaukee Brewers 24 = Washington Nationals 25 = New York Mets 26 = Philadelphia Phillies 27 = Pittsburgh Pirates 28 = St. Louis Cardinals 29 = San Diego Padres 30 = San Francisco Giants

Value

Returns a data frame with the respective park factors

Author(s)

Peter Xenopoulos

References

http://www.fangraphs.com/guts.aspx?type=pf&teamid=0&season=2014

See Also

handedparkfactors

Examples

## To get all of 2014 Park Factors # parkfactors(2014)

## To get all of the Angels' Park Factors # parkfactors(2014,1) 22 pyth

pyth

Description

Pythagorean expectation portrays what a team’s "should" be given it’s runs scored and allowed.

Usage

pyth(rs, ra, alpha = 2)

Arguments

rs Runs Scored ra Runs Allowed alpha Exponent to use

Details

2 and 1.83 are the most common exponents used. 1.83 is the exponent baseball-reference uses in its calculations.

Value

Returns a value equal to (rs^alpha)/(rs^alpha + ra^alpha)

Note

Pythagorean expectation can be used in a multitude of sports like basketball and football

Author(s)

Peter Xenopoulos

References

http://www.fangraphs.com/library/principles/expected-wins-and-losses/ https://en.wikipedia.org/wiki/Pythagorean_expectation

See Also

log5 raweqa 23

Examples ## Let's calculate the Angels 2014 Pythagorean Expectation ## The Angels had 773 Runs Scored and 630 Runs Allowed ## We should get an output close to .600 pyth(773,630,2)

## The function is currently defined as function (rs, ra, alpha = 2) { pyth <- (rs^alpha)/(rs^alpha + ra^alpha) return(pyth) }

raweqa Raw

Description Raw Equivalent Average is used to calculate Equivalent Average

Usage raweqa(AB, H, TB, BB, IBB, HBP, CS, SB, SH, SF)

Arguments AB At Bats H Hits TB BB Unintentional Walks IBB Intentional Walks HBP Hit By Pitches CS Caught Stealing SB Stolen Bases SH Sacrifice Hits SF Sacrifice Flies

Value Returns a numerical value equal to (H+TB+1.5*(BB+HBP+SB)+SH+SF-IBB/2)/(AB+BB+HBP+SH+SF+CS+SB)

Author(s) Peter Xenopoulos 24 secavg

References https://www.baseballprospectus.com/glossary/index.php?mode=viewstat&stat=61

See Also ops,slg,obp,iso,babip

Examples

## The function is currently defined as function (AB, H, TB, BB, IBB, HBP, CS, SB, SH, SF) { raweqa <- (H + TB + 1.5 * (BB + HBP + SB) + SH + SF - IBB/2)/(AB + BB + HBP + SH + SF + CS + SB) return(raweqa) }

secavg

Description Secondary average measure the sum of extra bases gained on hits, walks and stolen bases.

Usage secavg(ab, bb, tb, h, sb, cs)

Arguments ab At Bats bb Walks tb Total Bases h Hits sb Stolen Bases cs Caught Stealing

Details SecAvg shares no correlation with batting average although overall league averages are inclined to correspond with league batting averages.

Value Returns a numerical value equal to (bb+tb-h+sb-cs)/ab slg 25

Author(s) Peter Xenopoulos

References https://en.wikipedia.org/wiki/Secondary_average

See Also ops,slg,iso

Examples

## The function is currently defined as function (ab, bb, tb, h, sb, cs) { SecA <- (bb + tb - h + sb - cs)/ab return(SecA) }

slg Slugging Percentage

Description Slugging percentage is a measure of a hitter’s power.

Usage slg(TB, AB)

Arguments TB Total Bases AB At Bats

Value Returns a numerical value equal to (TB/AB) This is also equivalent to ((singles) + (2 x doubles) + (3 x triples) + (4 x homeruns))/(AB)

Author(s) Peter Xenopoulos 26 whip

References https://en.wikipedia.org/wiki/Slugging_percentage

See Also opsplus, ops

Examples ## Let's calculate Mike Trout's SLG for the 2014 season ## He had 338 TB's and 602 AB's ## We should get .561 as our output slg(338,602)

## The function is currently defined as function (TB, AB) { slugging <- (TB/AB) return(slugging) }

whip WHIP

Description WHIP (Walks + Hits Per Innings Pitched) describes how many base runners a pitcher gives up an inning.

Usage whip(h, bb, ip)

Arguments h Hits bb Walks ip Innings Pitched

Details WHIP is not a perfect indicator of pitcher skill. It is highly defense dependent. Hit rates are largely outside of pitcher control and have high fluctuations.

Value Returns a numerical value equal to (h+bb)/ip woba 27

Note

Innings Pitched (IP) is commonly reported with .1 indicating 1/3 of an inning and .2 indicating 2/3 of an inning. In order for this function to be accurate, please change the decimal to .333 for 1/3 of an inning and .666 for 2/3 of an inning.

Author(s)

Fernando Crema, Peter Xenopoulos

References

http://www.fangraphs.com/library/pitching/whip/ https://en.wikipedia.org/wiki/Walks_plus_hits_per_inning_pitched

See Also

era,fip,dice,xfip

Examples

## Let's look at Clayton Kershaw's WHIP for the 2014 season ## He gave up H = 139 and BB = 31 and pitched 198.33 innings ## We should get an output of 0.857 whip(139,31,198.33)

## The function is currently defined as function (h, bb, ip) { whip <- (h + bb)/ip return(whip) }

woba Weighted On-Base Average (wOBA)

Description

wOBA is a statistic which attempts to credit a batter for each outcome. It is reported as a rate.

Usage

woba(year, AB, BB, IBB, HBP, single, double, triple, HR, SF) 28 woba

Arguments year Season to use as context AB At Bats BB Unintentional Walks IBB Intentional Walks HBP Hit By Pitches single Singles double Doubles triple Triples HR Home Runs SF Sacrifice Flies

Details The linear weights used for this equation are in the linearWeights dataframe.

Value Returns a numeric value equal to ((wBB*BB)+(wHBP*HBP)+(w1B*single)+(w2B*double)+(w3B*triple)+(wHR*HR))/(AB+BB- IBB+SF+HBP) where wXX means weight of XX

Note wOBA is regarded as a better representation of a hitter’s skill than batting average or obp.

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/library/offense/woba/

See Also obp,wraa

Examples ## Let's calculate Mike Trout's 2014 wOBA ## He had 602 AB's, 83 BB's, 6 IBB's, 10 HBP's, ## 89 singles, 39 doubles, 9 triples, 36 homeruns, and 10 sac-flies ## We should get .408 as our output woba(2014,602,83,6,10,89,39,9,36,10)

## The function is currently defined as function (year, AB, BB, IBB, HBP, single, double, triple, HR, wraa 29

SF) { wBB <- linearWeights$wBB[which(weights$Season == year)] wHBP <- linearWeights$wHBP[which(weights$Season == year)] w1B <- linearWeights$w1B[which(weights$Season == year)] w2B <- linearWeights$w2B[which(weights$Season == year)] w3B <- linearWeights$w3B[which(weights$Season == year)] wHR <- linearWeights$wHR[which(weights$Season == year)] woba <- ((wBB * BB) + (wHBP * HBP) + (w1B * single) + (w2B * double) + (w3B * triple) + (wHR * HR))/(AB + BB - IBB + SF + HBP) return(woba) }

wraa Weighted Runs Above Average

Description wRAA measure the number of offensive runs a player contributes compared to an average player.

Usage wraa(woba, year, PA)

Arguments woba Weighted On Base Percentage. See woba year Season PA Plate Appearances

Details wRAA is league adjusted, meaning you can use it to compare players from different leagues and years.

Value Returns a value equal to ((wOBA - league wOBA) / wOBA scale) x PA

Note Usually, Ten wRAA is equivalent to +1 win.

Author(s) Peter Xenopoulos 30 wrc

References http://www.fangraphs.com/library/offense/wraa/

See Also woba

Examples ## Let's calculate Mike Trout's 2014 wRAA ## He had a wOBA of .402 and 705 PA's ## We should return 49.74 wraa(.402,2014,705)

## The function is currently defined as function (woba, year, PA) { wraa <- ((woba - linearWeights$wOBA[which(linearWeights$Season == year)])/weights$wOBAScale[which(linearWeights$Season == year)]) * PA return(wraa) }

wrc Weighted Runs Created

Description Weighted Runs Created is a statistic which attempts to credit a hitter for the value of each outcome.

Usage wrc(wOBA, PA, year)

Arguments wOBA Weighted On Base Average PA Plate Appearances year Season

Details wRC is reported with runs as the units

Value Returns a value equal to (((wOBA-linearWeights$wOBA[which(linearWeights$Season == year)])/linearWeights$wOBAScale[which(linearWeights$Season == year)])+weights$RPerPA[which(linearWeights$Season == year)])*PA wrcplus 31

Note

wRC is considered a better representation of offensive value than something like ops

Author(s)

Peter Xenopoulos

References

http://www.fangraphs.com/library/offense/wrc/

See Also

woba,wraa,wrcplus

Examples

## Let's calculate Mike Trout's 2014 wRC ## He had a wOBA of .402 and 705 PA's ## We should return 125.879 wrc(.402,705,2014)

## The function is currently defined as function (wOBA, PA, year) { wrc <- (((wOBA - linearWeights$wOBA[which(linearWeights$Season == year)])/linearWeights$wOBAScale[which(linearWeights$Season == year)]) + weights$RPerPA[which(linearWeights$Season == year)]) * PA return(wrc) }

wrcplus wRC+

Description

wRC+ is a statistic which attempts to credit a hitter for the value of each outcome.

Usage

wrcplus(wRAA, PA, year, parkfactor, leaguewRC) 32 wrcplus

Arguments

wRAA Weighted Runs Above Average (see wraa) PA Plate Appearances year Season parkfactor Park Factor leaguewRC League wRC

Details

wRC+ is scaled so that league average is 100, and each point above or below 100 is 1 percentage point better or worse than league average

Value

Returns a value equal to (((wRAA/PA + leaguerpa)+(leaguerpa-parkfactor*leaguerpa))/leaguewRC)*100

Note

wRC+ is a commonly used offensive statistic

Author(s)

Peter Xenopoulos

References

http://www.fangraphs.com/library/offense/wrc/

See Also

wraa,woba,wrc

Examples

## The function is currently defined as function (wRAA, PA, year, parkfactor, leaguewRC) { leaguerpa <- linearWeights$RPerPA[which(linearWeights$Season == year)] wrcplus <- (((wRAA/PA + leaguerpa) + (leaguerpa - parkfactor * leaguerpa))/leaguewRC) * 100 } wsb 33

wsb wSB

Description wSB is the estimated number of runs a player contributes by stealing bases as compared to the average player.

Usage wsb(year, SB, CS, lgwSB, single, bb, hbp, ibb)

Arguments year Season SB Stolen Bases CS Caught Stealing lgwSB League wSB single Singles bb Walks hbp Hit By Pitches ibb Intentional Walks

Details wSB is useful because it attaches a value to a player’s SB count

Value Returns a value equal to (SB * runSB) + (CS * runCS) - (lgwSB * (single + bb + hbp - ibb))

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/library/offense/wsb/

See Also lgwSB 34 xfip

Examples

## The function is currently defined as function (year, SB, CS, lgwSB, single, bb, hbp, ibb) { runSB <- linearWeights$runSB[which(linearWeights$Season == year)] runCS <- linearWeights$runCS[which(linearWeights$Season == year)] wsb <- (SB * runSB) + (CS * runCS) - (lgwSB * (single + bb + hbp - ibb)) }

xfip xFIP

Description

xFIP is a statistic that estimates a pitcher’s expected run prevention independent of the performance of the defense.

Usage xfip(flyballs, lgHRFB, BB, HBP, K, ip, year)

Arguments

flyballs Fly balls allowed lgHRFB League HR/FB Percentage BB Balls Allowed HBP Hit By Pitches Allowed K Strikeouts ip Innings Pitched year Season

Details

xFIP is almost exactly like FIP, except it uses the expected number of home runs taking the pitcher’s fly balls allowed times the league average home run per fly ball rate.

Value

Returns a numeric value equal to (13*(flyballs*lgHRFB)+(3*(BB+HBP))-(2*K))/(ip)+constant xfipminus 35

Note Innings Pitched (IP) is commonly reported with .1 indicating 1/3 of an inning and .2 indicating 2/3 of an inning. In order for this function to be accurate, please change the decimal to .333 for 1/3 of an inning and .666 for 2/3 of an inning.

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/library/pitching/xfip/

See Also fip,xfipminus

Examples ## The function is currently defined as function (flyballs, lgHRFB, BB, HBP, K, ip, year) { constant <- linearWeights$cFIP[which(linearWeights$Season == year)] xfip <- (13 * (flyballs * lgHRFB) + (3 * (BB + HBP)) - (2 * K))/(ip) + constant return(xfip) }

xfipminus xFIP-

Description xFIP- is a park-adjusted version of xFIP

Usage xfipminus(xFIP, ParkFactor, LeaguexFIP)

Arguments xFIP Player xFIP ParkFactor Park Factor LeaguexFIP League Average xFIP 36 xfipminus

Details League Average is set to 100 each season. Each point below or above 100 is one percentage point better or worse than league average.

Value Returns a value equal to (xFIP+(xFIP-(xFIP*(ParkFactor/100))))/(LeaguexFIP)*100

Note Park Factors can be found in the references section

Author(s) Peter Xenopoulos

References http://www.fangraphs.com/library/pitching/era-fip-xfip/ http://www.fangraphs.com/guts.aspx?type=pf&teamid=0&season=2014

See Also xfip,fipminus,eraminus

Examples ## The function is currently defined as function (xFIP, ParkFactor, LeaguexFIP) { xfipminus <- (xFIP + (xFIP - (xFIP * (ParkFactor/100))))/(LeaguexFIP) * 100 return(xfipminus) } Index

∗Topic \textasciitildekwd1 fipminus,8 log5, 16 ∗Topic fip ∗Topic \textasciitildekwd2 fip,7 log5, 16 ∗Topic handed park factors ∗Topic babip handedparkfactors, 11 babip,3 ∗Topic isolated power ∗Topic baseball analytics iso, 12 sabermetrics-package,2 ∗Topic iso ∗Topic baseball iso, 12 sabermetrics-package,2 ∗Topic league wsb ∗Topic batting average lgwSB, 13 babip,3 ∗Topic obp ∗Topic datasets obp, 17 linearWeights, 14 ∗Topic on base percentage ∗Topic defense independent pitching obp, 17 dice,4 ∗Topic on base plus slugging ∗Topic defense ops, 18 fp, 10 ∗Topic ops plus ∗Topic dice opsplus, 19 dice,4 ∗Topic ops+ ∗Topic average opsplus, 19 era,5 ∗Topic ops ∗Topic eqa ops, 18 raweqa, 23 ∗Topic park factors ∗Topic era minus handedparkfactors, 11 eraminus,6 parkfactors, 20 ∗Topic era- ∗Topic pythagorean eraminus,6 pyth, 22 ∗Topic era ∗Topic pyth era,5 pyth, 22 ∗Topic expected fip ∗Topic raa xfip, 34 wraa, 29 ∗Topic fielding independent ∗Topic raw eqa fip,7 raweqa, 23 ∗Topic fielding percentage ∗Topic runs above average fp, 10 wraa, 29 ∗Topic fip minus ∗Topic sabermetrics fipminus,8 sabermetrics-package,2 ∗Topic fip- ∗Topic secavg

37 38 INDEX

secavg, 24 handedparkfactors, 11, 21 ∗Topic secondary average secavg, 24 iso, 12, 24, 25 ∗Topic slg slg, 25 lgwSB, 13, 33 ∗Topic slugging percentage linearWeights, 14, 28 slg, 25 log5, 16, 22 ∗Topic obp, 3, 17, 18, 20, 24, 28 sabermetrics-package,2 ops, 3, 13, 17, 18, 20, 24–26, 31 ∗Topic stolen bases opsplus, 13, 18, 19, 26 wsb, 33 ∗Topic wSB parkfactors, 12, 20 wsb, 33 pyth, 16, 22 ∗Topic walks plus hits per inning pitched raweqa, 23 whip, 26 ∗Topic weighted on base sabermetrics (sabermetrics-package),2 woba, 27 sabermetrics-package,2 ∗Topic weighted runs created secavg, 24 wrc, 30 slg, 20, 24, 25, 25 ∗Topic whip whip, 26 whip, 4, 6, 8, 26 ∗Topic woba woba, 27, 29–32 woba, 27 wraa, 28, 29, 31, 32 ∗Topic wraa wrc, 30, 32 wraa, 29 wrcplus, 31, 31 ∗Topic wrc plus wsb, 14, 33 wrcplus, 31 xfip, 4, 6, 8, 27, 34, 36 ∗Topic wrc+ xfipminus, 7, 9, 35, 35 wrcplus, 31 ∗Topic wrc wrc, 30 ∗Topic xfip minus xfipminus, 35 ∗Topic xfip- xfipminus, 35 ∗Topic xfip xfip, 34 babip,3, 24 dice,4, 27 era, 4,5, 7,8 , 27 eraminus,6, 9, 36 fip, 4, 6,7, 9, 27, 35 fipminus, 7,8 ,8, 36 fp, 10