Introduction

Here is a brief illustration of using the WinProbability package just created on my Github site.

Install the package from Github:

library(devtools)
install_github("bayesball/WinProbability")

Load the package:

library(WinProbability)

Setup

Iā€™m in a folder where I have a raw Retrosheet play-by-play datafile. Note that the file must be of the form allYEAR.csv where YEAR is the value input in the function.

dir()
## [1] "all2018.csv"          "roster2018.csv"       "WinProbabilities.Rmd"

Compute runs expectancies

The compute.runs.expectancy function:

d2018 <- compute.runs.expectancy(2018)

Compute win probabilities

The compute.win.probs function will

d2018 <- compute.win.probs(d2018)

Graph the win probabilities for a game

The graph.game function will plot the win probabilities for all plays in a specific game.

plays <- graph.game(d2018, "SLN201805190")