This is the package that powers the A.I. Sports College Football 4th Down Model discussed in this UteZone article. The model is heavily based on the work and code produced by Ben Baldwin for his 4th Down Calculator for the NFL
Data freshness and pipeline status for every SportsDataverse dataset: sportsdataverse.org/status.
Installation
You can install the latest build from R-universe with:
install.packages("cfb4th", repos = c("https://sportsdataverse.r-universe.dev", getOption("repos")))You can install the development version of cfb4th from GitHub with:
if (!requireNamespace("pak", quietly = TRUE)) install.packages("pak")
pak::pak("sportsdataverse/cfb4th")
# or, with remotes:
# if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes")
# remotes::install_github("sportsdataverse/cfb4th")The models are the shared SportsDataverse college-football models, the same ones cfbfastR and sportsdataverse-py score: add_4th_probs() runs the fourth-down decision surface of cfbfastR, which downloads the models from the cfb_model_artifacts release of sportsdataverse-data the first time they are needed and caches them, so the first call to add_4th_probs() needs network access. Clear the cache to force a fresh download with cfb4th_clear_cache().
Quick start
library(cfb4th)
# a season of cfbfastR play-by-play with the fourth-down decision columns added
pbp <- load_4th_pbp(2020)
# the last fourth down of one game from ESPN, scored and laid out as a decision table
game <- data.frame(game_id = 401114223, home_team = "BYU", away_team = "Utah", week = 1)
plays <- get_4th_plays(game)
make_table_data(add_4th_probs(utils::tail(plays, 1)))The Get Started article walks through both workflows.
Features
- Go for it scores the fourth-down model’s distribution of yards gained (from a ten-yard loss to a 65-yard gain, given the down, distance, field position, the offense’s spread and implied total, and the season’s rule era): the game state after every outcome – a first down, a touchdown or a turnover on downs – is scored for win probability, and the results are weighted by each outcome’s probability
- Punt averages the win probability over an empirical distribution of where punts from that spot end up, return touchdowns included
- Field goal blends the win probabilities after a make and after a miss by the field-goal model’s make probability for the distance and era, which is zero beyond a 59-yard try and shaded down from about 52 yards
Current limitations
There are some edge cases that are not accounted for. These should only make a marginal difference to the recommendations as they are largely edge cases (e.g. the possibility for a field goal to be blocked and returned).
- Go for it does not allow for a turnover return. Long returns are extremely rare: in 2018 and 2019 in the NFL there were only four defensive touchdowns on plays where teams went for fourth downs out of 1,236 plays, and all of these happened when the game was well in hand for the other team. A touchdown counts six points before the kickoff; the extra point or two-point try is not modeled
- Punt doesn’t account for the punter or returner and ignores penalties on returns, and it is not scored inside the opponent’s 31, where the punt distribution has no data
- Field goal doesn’t account for who the kicker is, what the weather is (only relevant for outdoor games), or the possibility of a kick being blocked and returned for a touchdown
Get Started
To get started with cfb4th please see this article.
Companion packages
-
cfbfastR— the college football play-by-playload_4th_pbp()reads, and the fourth-down decision surfaceadd_4th_probs()runs. -
cfbseedR— simulate college football seasons, conference standings and the College Football Playoff. -
cfbplotRandsdvplotR— team logos, colors andgttables for plotting decisions.
The SportsDataverse
cfb4th is part of the SportsDataverse, a set of open-source packages for sports data.
| Package | Sport / Scope |
|---|---|
| cfbfastR | College football |
| hoopR | Men’s basketball (NBA and NCAA) |
| wehoop | Women’s basketball (WNBA and NCAA) |
| fastRhockey | Hockey (NHL and PWHL) |
| baseballr | Baseball (MLB, MiLB, NCAA) |
| softballR | College softball |
| oddsapiR | Sports betting odds |
| recruitR | College football recruiting |
| usfootballR | US soccer |
| cfbseedR · cfb4th | CFB playoff simulation · fourth-down decisions |
| cfbplotR · sdvplotR · sportyR | Logos, colors, tables · playing surfaces |
| sportsdataverse-R | Umbrella R metapackage |
| sportsdataverse-py · sportsdataverse.js | Python and Node.js |
See the full ecosystem at sportsdataverse.org.
Cheat sheet
A printable two-page reference for cfb4th, shared with sdvplotR and cfbseedR.
📄 Download the sdvplotR / cfb4th / cfbseedR cheat sheet (PDF)
Free to download, print and hand out; light and dark, US Letter landscape. Every SportsDataverse package has one — browse them all at sportsdataverse.org/cheatsheets.
License
cfb4th is released under the MIT License.
