footBayes
footBayes is an R package for the estimation, visualization and prediction of goal-based football models: double Poisson, bivariate Poisson, Dixon-Coles, negative binomial, Skellam, Student-\(t\), diagonal-inflated bivariate Poisson and zero-inflated Skellam. Models are fitted by maximum likelihood or in a Bayesian framework through Stan, with static or dynamic team abilities.
install.packages("footBayes", type = "source")

Key features
- Goal-based models: double Poisson, bivariate Poisson, Dixon-Coles, negative binomial, Skellam, Student-\(t\), diagonal-inflated bivariate Poisson and zero-inflated Skellam (Goal-based models in a nutshell).
- Inference: maximum likelihood with
mle_foot(), or Bayesian inference withstan_foot()through HMC, Pathfinder, ADVI and the Laplace approximation (Static models). - Dynamic abilities: weekly or seasonal team abilities, with common variance, variance inflation after the summer break, or weighted dynamic models with commensurate priors (Dynamic models).
- Checks, predictions and comparison: posterior predictive checks, match probabilities, league table reconstruction and model comparison through predictive metrics (Predictions).
Installation
footBayes requires the R package cmdstanr (not on CRAN) and CmdStan. For a step-by-step installation, follow Getting started with CmdStanR.
Released version (CRAN)
install.packages("footBayes", type = "source")Setting type = "source" is important: otherwise the CmdStan models in the package may not be compiled during installation.
Development version (GitHub)
# install.packages("devtools")
devtools::install_github("leoegidi/footBayes")A quick example
Fit a Bayesian double Poisson model to the Italian Serie A (seasons 2000/2001 to 2002/2003) and predict the last four match days of the 2002/2003 season:
library(footBayes)
library(dplyr)
data("italy")
italy_2000_2002 <- italy %>%
dplyr::select(Season, home, visitor, hgoal, vgoal) %>%
filter(Season %in% c("2000", "2001", "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",
predict = 36,
iter_sampling = 200,
chains = 2)
print(fit1, pars = c("att", "def"))foot_abilities(fit1, italy_2000_2002)
pp_foot(fit1, italy_2000_2002)
foot_rank(fit1, italy_2000_2002)
foot_prob(fit1, italy_2000_2002)
For the full workflow, see Get started and the articles.