Issue
In R/ep_preprocess.R[42-50], the calculation of implied_total in .preprocess_common_fields() reverses the logic for home and away teams. The result assigns the away implied total to both teams when the home team is favored.
Current output
Example using 2025_07_TB_DET:
| game_id |
posteam |
posteam_type |
spread_line |
total_line |
implied_total |
| 2025_07_TB_DET |
DET |
home |
6.0 |
54.5 |
24.25 |
| 2025_07_TB_DET |
TB |
away |
6.0 |
54.5 |
24.25 |
- In
nflverse play-by-play data, spread_line is from the home team’s perspective (+6 = home favored).
Expected behavior
- Home (DET):
implied_total = (total_line + spread_line) / 2 = (54.5 + 6.0) / 2 = 30.25
- Away (TB):
implied_total = (total_line - spread_line) / 2 = (54.5 - 6.0) / 2 = 24.25
Proposed fix
Replace the existing case_when() logic with:
implied_total = dplyr::if_else(
.data$posteam_type == "home",
(.data$total_line + .data$spread_line) / 2,
(.data$total_line - .data$spread_line) / 2
)
Issue
In
R/ep_preprocess.R[42-50], the calculation ofimplied_totalin.preprocess_common_fields()reverses the logic for home and away teams. The result assigns the away implied total to both teams when the home team is favored.Current output
Example using
2025_07_TB_DET:nflverseplay-by-play data,spread_lineis from the home team’s perspective (+6= home favored).Expected behavior
implied_total = (total_line + spread_line) / 2 = (54.5 + 6.0) / 2 = 30.25implied_total = (total_line - spread_line) / 2 = (54.5 - 6.0) / 2 = 24.25Proposed fix
Replace the existing
case_when()logic with: