makeWAR: Compute the runs above average (RAA) for each play.

Description Usage Arguments Details Value Examples

Description

Computes runs above average (RAA) for each player involved in each play of the GameDayPlays object.

Usage

 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, ...)

Arguments

x

An object of class GameDayPlays_*, where * can be the output of and of the seven steps listed below.

models

A named list of models, each with a predict method. See Details.

verbose

A logical indicating whether you want various messages and information to be displayed during the computation

low.memory

A logical indicating whether to conserve memory by not storing the model objects.

step

A logical indicating whether the function should stop after one of the seven steps.

...

currently ignored

Details

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.

Elements of models:

Value

An object of class openWARPlays which is a list containing the following:

Examples

 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)

beanumber/openWAR documentation built on May 12, 2019, 9:43 a.m.