Description Usage Arguments Details Value Examples
Computes runs above average (RAA) for each player involved in each play of the GameDayPlays
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | makeWAR(x, models = list(), verbose = TRUE, low.memory = TRUE,
step = FALSE, ...)
## S3 method for class 'GameDayPlays'
makeWAR(x, models = list(), verbose = TRUE,
low.memory = TRUE, step = FALSE, ...)
## S3 method for class 'GameDayPlays_Runs'
makeWAR(x, models = list(), verbose = TRUE,
low.memory = TRUE, step = FALSE, ...)
## S3 method for class 'GameDayPlays_Fielding'
makeWAR(x, models = list(), verbose = TRUE,
low.memory = TRUE, step = FALSE, ...)
## S3 method for class 'GameDayPlays_Pitching'
makeWAR(x, models = list(), verbose = TRUE,
low.memory = TRUE, step = FALSE, ...)
## S3 method for class 'GameDayPlays_Offense'
makeWAR(x, models = list(), verbose = TRUE,
low.memory = TRUE, step = FALSE, ...)
## S3 method for class 'GameDayPlays_Baserunning'
makeWAR(x, models = list(),
verbose = TRUE, low.memory = TRUE, step = FALSE, ...)
## S3 method for class 'GameDayPlays_Batters'
makeWAR(x, models = list(), verbose = TRUE,
low.memory = TRUE, step = FALSE, ...)
|
x |
An object of class |
models |
A named list of models, each with a |
verbose |
A |
low.memory |
A |
step |
A |
... |
currently ignored |
Within a GameDayPlays
object, each row consists of a single plate appearance and contains information about the batter, all of the baserunners,
the pitcher, and all of the fielders on the field during the plate appearance. The total value of the play as determined by the change in the run expectancy
matrix from the beginning of the plate appearence to the end of the plate appearance is partitioned across all players involved in the play on offense,
and that same value (with the opposite sign) is partitioned across the pitcher and all of the fielders. Thus for every single plate appearance a runs above average (RAA) value is assigned
to every player involved in the play.
If no models
argument is supplied, then all
models necessary for the computation of openWAR will be generated on the data set given.
The output of this function is then used in the function getWAR
to calculate a Wins Above Replacement (WAR) value for each player.
If verbose == TRUE
, then various pieces of information will be displayed during the computation.
The makeWAR
algorithm consists of seven steps, each of which appends columns to the original data frame.
Compute the change in run expectancy (δ) on each plate appearance
Partition -δ among the fielders using makeWARFielding
Partition the remaining δ for the pitcher using getModelPitching
Adjust δ for cicumstance, and attribute it to the offense using getModelOffense
Partition some of δ for the baserunners, using getModelBaserunning
Attribute the rest of δ to the batter, and adjust using getModelBatting
Parition the baserunning δ to the various baserunners, using makeWARBaserunning
Elements of models
:
run-expectancy: a model for assigning a run expectancy value to any of the 24 (base,out) states. Variables
must be startCode
[0-7] and startOuts
[0-2]
pitching: a model for the expected outcome of a plate appearance attributable to the pitcher. Variables
must be venueId
, throws
[L/R], and stands
[L/R]
offense: a model for the expected outcome of a plate appearance attributable to the offense. Variables
must be venueId
, throws
[L/R], and stands
[L/R]
baserunning: a model for the expected contribution of the baserunners to a plate appearance. Variables
must be event
(the type of batting event), startCode
[0-7], and startOuts
[0-2]
batting: a model for the expected contribution of the batter to a plate appearance. Variables
must be batterPos
(the defensive position of the batter)
An object of class openWARPlays
which is a list containing the following:
dataA data.frame containing the original data along with appended
rows containing the RAA values for each player involved in a plate appearance.
NULL if low.memory
is TRUE.
models.usedA list containing all of the model information for each
of the models used in computing RAA. NULL if low.memory
is TRUE.
openWARPlaysA data.frame of class openWARPlays
containing only the columns necessry for input into the getWAR function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ## Not run:
res <- makeWAR(May)
summary(getWAR(res))
print(object.size(res), units = "Mb")
res <- makeWAR(May, low.memory = FALSE)
print(object.size(res), units = "Mb"
names(res$models.used)
## End(Not run)
res <- makeWAR(May, step = TRUE)
print(object.size(res), units = "Mb")
## Not run:
res <- makeWAR(May, step = TRUE)
print(object.size(res), units = "Mb")
res2 <- makeWAR(res, step = TRUE)
print(object.size(res2), units = "Mb")
res3 <- makeWAR(res2, step = TRUE)
print(object.size(res3), units = "Mb")
res4 <- makeWAR(res3, step = TRUE)
print(object.size(res4), units = "Mb")
res5 <- makeWAR(res4, step = TRUE)
print(object.size(res5), units = "Mb")
res6 <- makeWAR(res5, step = TRUE)
print(object.size(res6), units = "Mb")
res7 <- makeWAR(res6, step = TRUE)
print(object.size(res7), units = "Mb")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.