mle_foot: Fit football models with Maximum Likelihood

View source: R/mle_foot.R

mle_footR Documentation

Fit football models with Maximum Likelihood

Description

Fits football goal-based models using maximum likelihood estimation. Supported models include: double Poisson, bivariate Poisson, Skellam, and Student's t.

Usage

mle_foot(
  data,
  model,
  predict = 0,
  maxit = 1000,
  method = "BFGS",
  interval = "profile",
  hessian = FALSE,
  sigma_y = 1
)

Arguments

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

model

A character specifying the model to fit. Options are:

  • "double_pois": Double Poisson model.

  • "biv_pois": Bivariate Poisson model.

  • "skellam": Skellam model.

  • "student_t": Student's t model.

predict

An integer specifying the number of out-of-sample matches for prediction. If missing, the function fits the model to the entire dataset without making predictions.

maxit

An integer specifying the maximum number of optimizer iterations default is 1000).

method

A character specifying the optimization method. Options are

  • "Nelder-Mead".

  • "BFGS" (default).

  • "CG".

  • "L-BFGS-B".

  • "SANN".

  • "Brent".

For further details see {optim} function in stats package.

interval

A character specifying the interval type for confidence intervals. Options are

  • "profile" (default).

  • "Wald".

hessian

A logical value indicating to include the computation of the Hessian (default FALSE).

sigma_y

A positive numeric value indicating the scale parameter for Student t likelihood (default 1).

Details

MLE can be obtained only for static models, with no time-dependence. Likelihood optimization is performed via the BFGS method of the {optim} function in stats package.

Value

A named list containing:

  • att: A matrix of attack ratings, with MLE and 95% confidence intervals (for "double_pois", "biv_pois" and "skellam" models).

  • def: A matrix of defence ratings, with MLE and 95% confidence intervals (for "double_pois", "biv_pois" and "skellam" models).

  • abilities: A matrix of combined ability, with MLE and 95% confidence intervals (for "student_t" only).

  • home_effect: A matrix with with MLE and 95% confidence intervals for the home effect estimate.

  • corr: A matrix with MLE and 95% confidence intervals for the bivariate Poisson correlation parameter (for "biv_pois" only).

  • model: The name of the fitted model (character).

  • predict: The number of out-of-sample matches used for prediction (integer).

  • sigma_y: The scale parameter used in the Student t likelihood (for "student_t" only).

  • team1_prev: Integer indices of home teams in the out-of-sample matches (if predict > 0).

  • team2_prev: Integer indices of away teams in the out-of-sample matches (if predict > 0).

  • logLik: The maximized log likelihood (numeric).

  • aic: Akaike Information Criterion (numeric).

  • bic: Bayesian Information Criterion (numeric).

Author(s)

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

References

Baio, G. and Blangiardo, M. (2010). Bayesian hierarchical model for the prediction of football results. Journal of Applied Statistics 37(2), 253-264.

Egidi, L., Pauli, F., and Torelli, N. (2018). Combining historical data and bookmakers' odds in modelling football scores. Statistical Modelling, 18(5-6), 436-459.

Gelman, A. (2014). Stan goes to the World Cup. From "Statistical Modeling, Causal Inference, and Social Science" blog.

Karlis, D. and Ntzoufras, I. (2003). Analysis of sports data by using bivariate poisson models. Journal of the Royal Statistical Society: Series D (The Statistician) 52(3), 381-393.

Karlis, D. and Ntzoufras,I. (2009). Bayesian modelling of football outcomes: Using the Skellam's distribution for the goal difference. IMA Journal of Management Mathematics 20(2), 133-145.

Owen, A. (2011). Dynamic Bayesian forecasting models of football match outcomes with estimation of the evolution variance parameter. IMA Journal of Management Mathematics, 22(2), 99-113.

Examples

## Not run: 
library(dplyr)

data("italy")
italy <- as_tibble(italy)
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")

mle_fit <- mle_foot(
  data = italy_2000_2002,
  model = "double_pois"
)

## End(Not run)


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