Get various probabilities associated with each option on PATs (go for it, kick PAT).
add_2pt_probs(df)
A data frame of decisions to be computed for.
Original data frame Data frame plus the following columns added:
Win probability when scoring 0 points on PAT.
Win probability when scoring 1 point on PAT.
Win probability when scoring 2 points on PAT.
Probability of making PAT kick.
Probability of converting 2-pt attempt.
Win probability associated with going for 1.
Win probability associated with going for 2.
play <-
tibble::tibble(
# things to help find the right game (use "reg" or "post")
home_team = "GB",
away_team = "TB",
posteam = "GB",
type = "post",
season = 2020,
# information about the situation
qtr = 4,
quarter_seconds_remaining = 123,
score_differential = -2,
home_opening_kickoff = 0,
posteam_timeouts_remaining = 3,
defteam_timeouts_remaining = 3
)
probs <- nfl4th::add_2pt_probs(play)
#> Computing probabilities for 1 plays. . .
#> [16:25:19] WARNING: amalgamation/../src/learner.cc:438:
#> If you are loading a serialized model (like pickle in Python, RDS in R) generated by
#> older XGBoost, please export the model by calling `Booster.save_model` from that version
#> first, then load it back in current version. See:
#>
#> https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html
#>
#> for more details about differences between saving model and serializing.
#>
#> [16:25:20] WARNING: amalgamation/../src/learner.cc:438:
#> If you are loading a serialized model (like pickle in Python, RDS in R) generated by
#> older XGBoost, please export the model by calling `Booster.save_model` from that version
#> first, then load it back in current version. See:
#>
#> https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html
#>
#> for more details about differences between saving model and serializing.
#>
#> [16:25:20] WARNING: amalgamation/../src/learner.cc:438:
#> If you are loading a serialized model (like pickle in Python, RDS in R) generated by
#> older XGBoost, please export the model by calling `Booster.save_model` from that version
#> first, then load it back in current version. See:
#>
#> https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html
#>
#> for more details about differences between saving model and serializing.
#>
dplyr::glimpse(probs)
#> Rows: 1
#> Columns: 18
#> $ home_team <chr> "GB"
#> $ away_team <chr> "TB"
#> $ posteam <chr> "GB"
#> $ type <chr> "post"
#> $ season <dbl> 2020
#> $ qtr <dbl> 4
#> $ quarter_seconds_remaining <dbl> 123
#> $ score_differential <dbl> -2
#> $ home_opening_kickoff <dbl> 0
#> $ posteam_timeouts_remaining <dbl> 3
#> $ defteam_timeouts_remaining <dbl> 3
#> $ wp_0 <dbl> 0.2119228
#> $ wp_1 <dbl> 0.2721162
#> $ wp_2 <dbl> 0.4371383
#> $ conv_1pt <dbl> 0.9334797
#> $ conv_2pt <dbl> 0.588913
#> $ wp_go1 <dbl> 0.2681121
#> $ wp_go2 <dbl> 0.3445551