Skip to contents

All teams are ranked (if possible) by their contribution to the scoring variable.

Usage

get_ranking_by_diff_one(data, variable, method = "normal")

Arguments

data

tibble of match information - it is assumed that each line corresponds to the score breakdown of one team in one event's match.

variable

numeric measurement.

method

character which model should be calculated? Either normal or loglinear.

Value

tibble of the teams (team_key), their rating(s) and the number of matches (n) the ratings are based on.

Details

In order to model each team's contribution, a wide data set has to be constructed, with each team as a variable, and each row as one of the alliances in one match and their score. An alliance in a match consists of exactly three robots. This requirement is checked before modelling and if not fulfilled, results in a warning. A normal model is then fitted, or, if method = "loglinear" a log-linear model is fitted, if all values in the scoring variable are non-negative. The coefficients of this model can be interpreted as the average (log) contribution of that team to the score of a match.

Examples

# example code
# get all matches for one event:
matches <- get_records("event/2024iawes/matches")
# get the score breakdown for each of the teams in each match
match_details <- get_match_details(matches)

library(dplyr, quietly=TRUE)
# now get the contribution to the score:
match_details %>% filter(comp_level == "qm") %>% # get the qualifying matches
  get_ranking_by_diff_one(score)
#> # A tibble: 11 × 3
#>    team_key `rating_diff(score)`     n
#>    <chr>                   <dbl> <int>
#>  1 frc3928                11.8      11
#>  2 frc5041                10.4      11
#>  3 frc525                  0.742    11
#>  4 frc6317                -1.84     11
#>  5 frc6419                -4.35     11
#>  6 frc9999                -5.08     11
#>  7 frc9998                -8.20     11
#>  8 frc9997                -8.34     11
#>  9 frc9996                -8.51     11
#> 10 frc967                -13.1      11
#> 11 frc9995               -21.5      11
# These coefficients correspond to the OPR 

# team contribution to the score without counting the opponents' fouls:
match_details %>% filter(comp_level == "qm") %>% # get the qualifying matches
  get_ranking_by_diff_one(score-foulPoints)
#> # A tibble: 11 × 3
#>    team_key `rating_diff(score - foulPoints)`     n
#>    <chr>                                <dbl> <int>
#>  1 frc3928                              9.72     11
#>  2 frc5041                              3.52     11
#>  3 frc525                               0.810    11
#>  4 frc6317                             -3.20     11
#>  5 frc9998                             -6.85     11
#>  6 frc9999                             -8.99     11
#>  7 frc9997                             -9.03     11
#>  8 frc6419                             -9.24     11
#>  9 frc9996                            -13.2      11
#> 10 frc967                             -14.3      11
#> 11 frc9995                            -25.6      11