foot_abilities {footBayes}R Documentation

Plot football abilities from Stan and MLE models

Description

Depicts teams' abilities either from the Stan models fitted via the stan_foot function or from MLE models fitted via the mle_foot function.

Usage

foot_abilities(
  object,
  data,
  type = c("attack", "defense", "both"),
  teams = NULL,
  ...
)

Arguments

object

An object either of class stanfit or stanFoot as given by stan_foot function, or class list containing the Maximum Likelihood Estimates (MLE) for the model parameters fitted with mle_foot.

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).

type

Type of ability in Poisson models: one among "defense", "attack" or "both".

teams

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

...

Optional graphical parameters.

Value

Abilities plots for the selected teams: for Poisson models only, red denotes the attack, blue the defense.

Author(s)

Leonardo Egidi legidi@units.it

Examples

## Not run: 
library(dplyr)

data("italy")
italy <- as_tibble(italy)

### no dynamics, no prediction

italy_2000_2002 <- italy %>%
 dplyr::select(Season, home, visitor, hgoal, vgoal) %>%
 dplyr::filter(Season=="2000" |  Season=="2001" | Season =="2002")

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

fit1 <- stan_foot(data = italy_2000_2002,
                  model="double_pois") # double poisson

fit2 <- stan_foot(data = italy_2000_2002,
                  model="biv_pois")    # bivariate poisson

fit3 <- stan_foot(data = italy_2000_2002,
                  model="skellam")     # skellam

fit4 <- stan_foot(data = italy_2000_2002,
                  model="student_t")   # student_t

foot_abilities(fit1, italy_2000_2002)
foot_abilities(fit2, italy_2000_2002)
foot_abilities(fit3, italy_2000_2002)
foot_abilities(fit4, italy_2000_2002)

### seasonal dynamics, predict the last season

fit5 <-stan_foot(data = italy_2000_2002,
                 model = "biv_pois",
                 predict = 180,
                 dynamic_type = "seasonal")   # bivariate poisson
foot_abilities(fit5, italy_2000_2002)


## End(Not run)

[Package footBayes version 1.0.0 Index]