Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,16 @@ the `httr2` and `testthat` floors (see Dependencies). (#84)
* `load_ncaa_wbb_rapm_within_team()` documented `rapm_net` as `rapm_off + rapm_def`. The data
has `rapm_net = rapm_off - rapm_def`, because `rapm_def` is on a points-allowed scale (lower
is better). The docs now say so.
* The returns tables of the three model loaders now list every column of the published files:
`load_wnba_player_impact()` 76 (was 28; adds the `_n`, `_rank` and `_pct` columns of each
of the 16 ratings), `load_wbb_ratings()` 16 (was 11; adds `adj_o_blend`, `adj_d_blend`,
`adj_em_blend`, `rank_blend` and `prior_games`) and `load_wbb_player_value()` 9 (was 8; adds
`qualified`). `o_adj_rapm` / `d_adj_rapm` were documented as adjusted for minutes/possession
stability; they are RAPM with a ridge prior toward SPM (last season's in the regular season,
this season's regular-season SPM in the playoffs). `load_wbb_player_value()` documented
`player_id` as a stats.ncaa.org id; it is the ESPN athlete id. The team-ratings and
player-value articles no longer say 2015 is missing, that there is no preseason prior, or that
older files lack `qualified`.
* The installed help is a third smaller (4.4 MB to 3.0 MB). The help pages of the 9 largest
function families (ESPN WNBA and WBB, WNBA Player and Team, FIBA, TBF, SCB, NBL Rosetta,
WJBL) link to one family index page (`?family_espn_wnba`, `?family_tbf`, ...) in "See also"
Expand Down
84 changes: 74 additions & 10 deletions R/load_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @rdname load_wbb_player_value
#' @author Saiem Gilani
#' @description Loads season-level WNBA player-impact ratings -- one row per
#' player-team-season, combining regularized adjusted plus-minus (RAPM),
#' player, team, season and season type, combining regularized adjusted plus-minus (RAPM),
#' statistical plus-minus (SPM), box plus-minus (BPM), wins above
#' replacement (WAR), and a DARKO-style skill/projection pair. Produced by
#' the sportsdataverse-py NBA/WNBA possession-engine model program; published to the
Expand All @@ -29,7 +29,14 @@
#' the season data into a database.
#' @param dbConnection A `DBIConnection` object, as returned by [DBI::dbConnect()]
#' @param tablename The name of the data table within the database
#' @return Returns a `wehoop_data` tibble with one row per player-team-season.
#' @return `load_wnba_player_impact()` returns a `wehoop_data` tibble with one
#' row per player, team, season and season type (`Regular Season` and
#' `Playoffs` rows are separate).
#' Each of the 16 ratings gets an `_n` (sample size), `_rank` and `_pct`
#' column, computed within each season and season type. The sample gates
#' are regular-season sized: in the published 1997-2026 files no season has
#' 10 playoff players past a gate, so every playoff `_rank` and `_pct` is
#' null except `war_rank` and `war_pct`.
#'
#' \if{html}{\tabular{lll}{
#' col_name \tab types \tab description \cr
Expand All @@ -46,8 +53,8 @@
#' rapm \tab numeric \tab Net regularized adjusted plus-minus (o_rapm + d_rapm). \cr
#' off_poss \tab integer \tab Offensive possessions used in the RAPM fit. \cr
#' def_poss \tab integer \tab Defensive possessions used in the RAPM fit. \cr
#' o_adj_rapm \tab numeric \tab Offensive RAPM adjusted for minutes/possession stability. \cr
#' d_adj_rapm \tab numeric \tab Defensive RAPM adjusted for minutes/possession stability. \cr
#' o_adj_rapm \tab numeric \tab Offensive RAPM fitted with a ridge prior toward SPM instead of zero: the previous season's SPM in the regular season, the same season's regular-season SPM in the playoffs. A player with no prior (a first season, or after a gap) is shrunk toward zero. \cr
#' d_adj_rapm \tab numeric \tab Defensive RAPM fitted with a ridge prior toward SPM instead of zero: the previous season's SPM in the regular season, the same season's regular-season SPM in the playoffs. A player with no prior (a first season, or after a gap) is shrunk toward zero. \cr
#' adj_rapm \tab numeric \tab Net adjusted RAPM (o_adj_rapm + d_adj_rapm). \cr
#' ospm \tab numeric \tab Offensive statistical plus-minus (box-score component). \cr
#' dspm \tab numeric \tab Defensive statistical plus-minus (box-score component). \cr
Expand All @@ -61,6 +68,54 @@
#' boban_filtered_skill \tab numeric \tab DARKO-style filtered skill rating. \cr
#' boban_projected_rating \tab numeric \tab DARKO-style forward-looking projected rating. \cr
#' boban_projected_sd \tab numeric \tab Standard deviation of the DARKO-style projected rating. \cr
#' o_rapm_n \tab integer \tab Possessions o_rapm is measured over (off_poss). Its rank and percentile are set only when it reaches 610, the WNBA sample at which an offensive on-court rating is half signal. \cr
#' d_rapm_n \tab integer \tab Possessions d_rapm is measured over (def_poss). Its rank and percentile are set only when it reaches 1,200, the WNBA sample at which a defensive on-court rating is half signal. \cr
#' rapm_n \tab integer \tab Possessions rapm is measured over (off_poss + def_poss). Its rank and percentile are set only when it reaches 1,600, the WNBA sample at which a net on-court rating is half signal. \cr
#' o_adj_rapm_n \tab integer \tab Possessions o_adj_rapm is measured over (off_poss). Its rank and percentile are set only when it reaches 610, the WNBA sample at which an offensive on-court rating is half signal. \cr
#' d_adj_rapm_n \tab integer \tab Possessions d_adj_rapm is measured over (def_poss). Its rank and percentile are set only when it reaches 1,200, the WNBA sample at which a defensive on-court rating is half signal. \cr
#' adj_rapm_n \tab integer \tab Possessions adj_rapm is measured over (off_poss + def_poss). Its rank and percentile are set only when it reaches 1,600, the WNBA sample at which a net on-court rating is half signal. \cr
#' ospm_n \tab integer \tab Possessions ospm is measured over (off_poss). Its rank and percentile are set only when it reaches 610, the WNBA sample at which an offensive on-court rating is half signal. \cr
#' dspm_n \tab integer \tab Possessions dspm is measured over (def_poss). Its rank and percentile are set only when it reaches 1,200, the WNBA sample at which a defensive on-court rating is half signal. \cr
#' spm_n \tab integer \tab Possessions spm is measured over (off_poss + def_poss). Its rank and percentile are set only when it reaches 1,600, the WNBA sample at which a net on-court rating is half signal. \cr
#' obpm_n \tab integer \tab Possessions obpm is measured over (off_poss). Its rank and percentile are set only when it reaches 610, the WNBA sample at which an offensive on-court rating is half signal. \cr
#' dbpm_n \tab integer \tab Possessions dbpm is measured over (def_poss). Its rank and percentile are set only when it reaches 1,200, the WNBA sample at which a defensive on-court rating is half signal. \cr
#' bpm_n \tab integer \tab Possessions bpm is measured over (off_poss + def_poss). Its rank and percentile are set only when it reaches 1,600, the WNBA sample at which a net on-court rating is half signal. \cr
#' war_n \tab integer \tab Possessions behind war (off_poss + def_poss). war is a count, not a rate, so its rank has no sample gate. \cr
#' boban_filtered_skill_n \tab integer \tab Possessions behind boban_filtered_skill (off_poss + def_poss this season). A multi-season estimate takes the net gate: its rank and percentile are set only when it reaches 1,600. \cr
#' boban_projected_rating_n \tab integer \tab Possessions behind boban_projected_rating (off_poss + def_poss this season). A multi-season estimate takes the net gate: its rank and percentile are set only when it reaches 1,600. \cr
#' boban_projected_sd_n \tab integer \tab Possessions behind boban_projected_sd (off_poss + def_poss this season). A multi-season estimate takes the net gate: its rank and percentile are set only when it reaches 1,600. \cr
#' o_rapm_rank \tab numeric \tab Rank of o_rapm within the season and season type, 1 = best, ties averaged. Null when o_rapm is null, o_rapm_n is under 610, or fewer than 10 players are ranked. \cr
#' d_rapm_rank \tab numeric \tab Rank of d_rapm within the season and season type, 1 = best, ties averaged. Null when d_rapm is null, d_rapm_n is under 1,200, or fewer than 10 players are ranked. \cr
#' rapm_rank \tab numeric \tab Rank of rapm within the season and season type, 1 = best, ties averaged. Null when rapm is null, rapm_n is under 1,600, or fewer than 10 players are ranked. \cr
#' o_adj_rapm_rank \tab numeric \tab Rank of o_adj_rapm within the season and season type, 1 = best, ties averaged. Null when o_adj_rapm is null, o_adj_rapm_n is under 610, or fewer than 10 players are ranked. \cr
#' d_adj_rapm_rank \tab numeric \tab Rank of d_adj_rapm within the season and season type, 1 = best, ties averaged. Null when d_adj_rapm is null, d_adj_rapm_n is under 1,200, or fewer than 10 players are ranked. \cr
#' adj_rapm_rank \tab numeric \tab Rank of adj_rapm within the season and season type, 1 = best, ties averaged. Null when adj_rapm is null, adj_rapm_n is under 1,600, or fewer than 10 players are ranked. \cr
#' ospm_rank \tab numeric \tab Rank of ospm within the season and season type, 1 = best, ties averaged. Null when ospm is null, ospm_n is under 610, or fewer than 10 players are ranked. \cr
#' dspm_rank \tab numeric \tab Rank of dspm within the season and season type, 1 = best, ties averaged. Null when dspm is null, dspm_n is under 1,200, or fewer than 10 players are ranked. \cr
#' spm_rank \tab numeric \tab Rank of spm within the season and season type, 1 = best, ties averaged. Null when spm is null, spm_n is under 1,600, or fewer than 10 players are ranked. \cr
#' obpm_rank \tab numeric \tab Rank of obpm within the season and season type, 1 = best, ties averaged. Null when obpm is null, obpm_n is under 610, or fewer than 10 players are ranked. \cr
#' dbpm_rank \tab numeric \tab Rank of dbpm within the season and season type, 1 = best, ties averaged. Null when dbpm is null, dbpm_n is under 1,200, or fewer than 10 players are ranked. \cr
#' bpm_rank \tab numeric \tab Rank of bpm within the season and season type, 1 = best, ties averaged. Null when bpm is null, bpm_n is under 1,600, or fewer than 10 players are ranked. \cr
#' war_rank \tab numeric \tab Rank of war within the season and season type, 1 = best, ties averaged. Ungated; null when war is null or fewer than 10 players are ranked. \cr
#' boban_filtered_skill_rank \tab numeric \tab Rank of boban_filtered_skill within the season and season type, 1 = best, ties averaged. Null when boban_filtered_skill is null, boban_filtered_skill_n is under 1,600, or fewer than 10 players are ranked. \cr
#' boban_projected_rating_rank \tab numeric \tab Rank of boban_projected_rating within the season and season type, 1 = best, ties averaged. Null when boban_projected_rating is null, boban_projected_rating_n is under 1,600, or fewer than 10 players are ranked. \cr
#' boban_projected_sd_rank \tab numeric \tab Rank of boban_projected_sd within the season and season type, ascending: 1 = the smallest sd (the most certain projection), ties averaged. Null when boban_projected_sd is null, boban_projected_sd_n is under 1,600, or fewer than 10 players are ranked. \cr
#' o_rapm_pct \tab numeric \tab Percentile of o_rapm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' d_rapm_pct \tab numeric \tab Percentile of d_rapm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' rapm_pct \tab numeric \tab Percentile of rapm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' o_adj_rapm_pct \tab numeric \tab Percentile of o_adj_rapm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' d_adj_rapm_pct \tab numeric \tab Percentile of d_adj_rapm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' adj_rapm_pct \tab numeric \tab Percentile of adj_rapm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' ospm_pct \tab numeric \tab Percentile of ospm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' dspm_pct \tab numeric \tab Percentile of dspm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' spm_pct \tab numeric \tab Percentile of spm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' obpm_pct \tab numeric \tab Percentile of obpm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' dbpm_pct \tab numeric \tab Percentile of dbpm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' bpm_pct \tab numeric \tab Percentile of bpm_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' war_pct \tab numeric \tab Percentile of war_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' boban_filtered_skill_pct \tab numeric \tab Percentile of boban_filtered_skill_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' boban_projected_rating_pct \tab numeric \tab Percentile of boban_projected_rating_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players; null where the rank is. \cr
#' boban_projected_sd_pct \tab numeric \tab Percentile of boban_projected_sd_rank, 100 x (n + 1 - rank) / (n + 1) over the n ranked players: high means a more certain projection. Null where the rank is. \cr
#' }}
#' \if{latex}{See the HTML help or pkgdown reference for the column table.}
#'
Expand Down Expand Up @@ -124,18 +179,20 @@ NULL
#' the season data into a database.
#' @param dbConnection A `DBIConnection` object, as returned by [DBI::dbConnect()]
#' @param tablename The name of the data table within the database
#' @return Returns a `wehoop_data` tibble with one row per player-team-season.
#' @return `load_wbb_player_value()` returns a `wehoop_data` tibble with one
#' row per player-team-season.
#'
#' \if{html}{\tabular{lll}{
#' col_name \tab types \tab description \cr
#' player_id \tab character \tab stats.ncaa.org player identifier. \cr
#' player_id \tab character \tab ESPN athlete identifier (the box score's athlete_id, as a string). \cr
#' player \tab character \tab Player display name (title-cased). \cr
#' season \tab integer \tab Season identifier (4-digit season-ending year). \cr
#' team_id \tab character \tab Unique team identifier. \cr
#' min \tab numeric \tab Minutes played. \cr
#' box_obpm \tab numeric \tab Box-score offensive box plus-minus. \cr
#' box_dbpm \tab numeric \tab Box-score defensive box plus-minus. \cr
#' box_bpm \tab numeric \tab Box-score net box plus-minus (box_obpm + box_dbpm). \cr
#' qualified \tab logical \tab TRUE when min is at least 300, the floor where the spread of box_bpm first sits within 2% of its high-minute plateau. An additive flag: no row is dropped. \cr
#' }}
#' \if{latex}{See the HTML help or pkgdown reference for the column table.}
#'
Expand Down Expand Up @@ -188,15 +245,17 @@ load_wbb_player_value <- function(seasons = most_recent_wbb_season(),
#' @description Loads season-level NCAA women's college basketball team
#' ratings -- one row per team-season, with adjusted
#' (opponent-strength-normalized) offensive/defensive efficiency, adjusted
#' tempo, raw efficiency, and a national rank. A KenPom-style
#' adjusted-efficiency-margin rating. This tag is parquet-only, with no
#' tempo, raw efficiency, and a rank by adj_em over every team in the file
#' (including non-Division I opponents), solved as an iterative fixed
#' point. This tag is parquet-only, with no
#' csv/rds sibling assets. Produced by the sportsdataverse-py NCAA WBB model program;
#' published to the `wbb_ratings` release tag.
#' @param ... Additional arguments passed to an underlying function that writes
#' the season data into a database.
#' @param dbConnection A `DBIConnection` object, as returned by [DBI::dbConnect()]
#' @param tablename The name of the data table within the database
#' @return Returns a `wehoop_data` tibble with one row per team-season.
#' @return `load_wbb_ratings()` returns a `wehoop_data` tibble with one row per
#' team-season.
#'
#' \if{html}{\tabular{lll}{
#' col_name \tab types \tab description \cr
Expand All @@ -209,8 +268,13 @@ load_wbb_player_value <- function(seasons = most_recent_wbb_season(),
#' raw_o \tab numeric \tab Unadjusted (raw) offensive efficiency. \cr
#' raw_d \tab numeric \tab Unadjusted (raw) defensive efficiency. \cr
#' games \tab integer \tab Games played (season total). \cr
#' rank \tab integer \tab National rank by adj_em. \cr
#' rank \tab integer \tab Rank by adj_em among every team in the file (dense, 1 = best; includes non-Division I opponents). \cr
#' adj_em_z \tab numeric \tab Z-score of adj_em relative to the season's team distribution. \cr
#' adj_o_blend \tab numeric \tab Adjusted offensive efficiency with the preseason prior blended in: the same fixed point as adj_o, with each Division I team shrunk toward last season's regressed rating as if it had played prior_games extra games at it. A team new to Division I (or with no rated game last season) is shrunk toward the 23rd percentile of last season's Division I adj_em instead. Non-Division I opponents get no prior; their values move only through their Division I opponents. \cr
#' adj_d_blend \tab numeric \tab Adjusted defensive efficiency with the preseason prior blended in, on the same basis as adj_o_blend (lower is better). \cr
#' adj_em_blend \tab numeric \tab adj_o_blend minus adj_d_blend. A team with g games is rated about g / (g + prior_games) on this season. \cr
#' rank_blend \tab integer \tab Rank by adj_em_blend among every team in the file (dense, 1 = best; includes non-Division I opponents). \cr
#' prior_games \tab numeric \tab Weight of the preseason prior, in games (3). 0 when the previous season has no ratable games (2009); the blend then equals the unblended rating. \cr
#' }}
#' \if{latex}{See the HTML help or pkgdown reference for the column table.}
#'
Expand Down
Loading
Loading