foot_rank: Rank and points predictions

View source: R/foot_rank.R

foot_rankR Documentation

Rank and points predictions

Description

Posterior predictive plots and final rank table for football seasons.

Usage

foot_rank(object, data, teams = NULL, visualize = "individual")

Arguments

object

An object either of class stanFoot, CmdStanFit, or stanfit.

data

A data frame containing match data with columns:

  • periods: Time point of each observation (integer >= 1).

  • home_team: Home team's name (character string).

  • away_team: Away team's name (character string).

  • home_goals: Goals scored by the home team (integer >= 0).

  • away_goals: Goals scored by the away team (integer >= 0).

teams

An optional character vector specifying team names to include. If NULL, all teams are included.

visualize

Type of plots, one among "aggregated" or "individual". Default is "individual".

Details

For Bayesian models fitted via stan_foot the final rank tables are computed according to the simulation from the posterior predictive distribution of future (out-of-sample) matches. The dataset should refer to one or more seasons from a given national football league (Premier League, Serie A, La Liga, etc.).

Value

If visualize = "aggregated": a list with

  • rank_table: A data frame of observed and simulated final points (median, 25%/75% quantiles).

  • rank_plot: A ggplot comparing observed vs simulated final points for each team.

If visualize = "individual": A ggplot showing, for each selected team, the observed and simulated cumulative points over match‑days.

Author(s)

Leonardo Egidi legidi@units.it and Roberto Macrì Demartino roberto.macridemartino@deams.units.it

Examples

## Not run: 
if (instantiate::stan_cmdstan_exists()) {
  library(dplyr)

  data("italy")
  italy_1999_2000 <- italy %>%
    dplyr::select(Season, home, visitor, hgoal, vgoal) %>%
    dplyr::filter(Season == "1999" | Season == "2000")

  colnames(italy_1999_2000) <- c("periods", "home_team", "away_team", "home_goals", "away_goals")

  fit <- stan_foot(italy_1999_2000, "double_pois", iter_sampling = 200)
  foot_rank(fit, italy_1999_2000)
  foot_rank(fit, italy_1999_2000, visualize = "individual")
}

## End(Not run)


LeoEgidi/footBayes documentation built on June 2, 2025, 11:32 a.m.