Computes runs above average (RAA) for each player involved in each play of the GameDayPlays
object.
makeWAR(data, models = list(), verbose = TRUE, low.memory = TRUE, ...)# S3 method for GameDayPlays
makeWAR(data, models = list(), verbose = TRUE,
low.memory = TRUE, ...)
An object of class GameDayPlays
A named list of models, each with a predict() method. See Details.
A logical
indicating whether you want various messages
and information to be displayed during the computation
A logical
indicating whether to conserve memory by
not storing the model objects.
currently ignored
An object of class openWARPlays
which is a list of length 4 containing the following:
playsA data.frame of class GameDayPlays
that is the same as the input to the function.
dataA data.frame of class GameDayPlaysExt
containing the original data along with appended rows containing the RAA values for each player involved in a plate appearance
models.usedA list containing all of the model information for each of the models used in computing RAA.
openWARA data.frame of class openWARPlays
containing only the columns necessry for input into the getWAR function.
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 comuptation.
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)
# NOT RUN {
res = makeWAR(May)
summary(getWAR(res))
# }
Run the code above in your browser using DataLab