plot.chain {runexp}R Documentation

Plots an object of S3 class "chain"

Description

Acts on a "chain" object output from the "chain" function. Plots convergence of chain, expected score by state, and expected score by lead-off batter (if applicable).

Usage

## S3 method for class 'chain'
plot(x, type = 1:2, lead_off = 1, fast = FALSE, ...)

Arguments

x

object of class "chain"

type

denotes which type of plot to generate - 1, 2, 3, or any combination of these. See details for plot descriptions.

lead_off

an integer 1-9. Denotes which lead-off batter to plot in type 1 and type 2 plots. Lead-off batters 2-9 are only available if chain was calculated with cycle = TRUE.

fast

logical indicating whether to plot additional fast player states in type 1 and type 2 plots.

...

NA

Details

This function generates three types of plots:

Both type 1 and type 2 plots rely on the specification of a lead-off batter. In states with runners on base and/or outs, the lead-off batter refers to the first batter to come up to to the plate starting in that situation, not the first batter to start the inning. The "true" lead-off batter at the start of the inning corresponds to the R0 (no runners) 0 out case.

Value

No return value, called to generate plots.

Examples

# Expected score for single batter (termed "offensive potential")
chain1 <- chain("B", wku_probs)
plot(chain1)

# Expected score without cycling
lineup <- wku_probs$name[1:9]
chain2 <- chain(lineup, wku_probs)
plot(chain2)

# Expected score with cycling
chain3 <- chain(lineup, wku_probs, cycle = TRUE)
plot(chain3, type = 1:3)
        

[Package runexp version 0.2.1 Index]