The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

footBayes

CRAN Version Dev Version R-CMD-check.yaml Codecov test coverage Downloads

The goal of footBayes is to propose a complete workflow to:

Installation

Starting with version 2.0.0, footBayes package requires installing the R package cmdstanr (not available on CRAN) and the command-line interface to Stan: CmdStan. For a step-by-step installation, please follow the instructions provided in Getting started with CmdStanR.

You can install the released version of footBayes from CRAN with:

install.packages("footBayes", type = "source")

Please note that it is important to set type = "source". Otherwise, the ‘CmdStan’ models in the package may not be compiled during installation.

Alternatively to CRAN, you can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("leoegidi/footBayes")

Example

In what follows, a quick example to fit a Bayesian double Poisson model for the Italian Serie A (seasons 2000-2001, 2001-2002, 2002-2003), visualize the estimated teams’ abilities, and predict the last four match days for the season 2002-2003:

library(footBayes)
library(dplyr)
# Dataset for Italian Serie A
data("italy")
italy <- as_tibble(italy)
italy_2000_2002 <- italy %>%
  dplyr::select(Season, home, visitor, hgoal, vgoal) %>%
  filter(Season == "2000" | Season == "2001" | Season == "2002")

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

# Double poisson fit (predict last 4 match-days)
fit1 <- stan_foot(data = italy_2000_2002,
                  model = "double_pois",
                  predict = 36,
                  iter_sampling = 200,
                  chains = 2) 

The results (i.e., attack and defense effects) can be investigated using

print(fit1, pars = c("att", "def"))

To visually investigate the attack and defense effects, we can use the foot_abilities function

foot_abilities(fit1, italy_2000_2002) # teams abilities

To check the adequacy of the Bayesian model the function pp_foot provides posterior predictive plots

pp_foot(fit1, italy_2000_2002) # pp checks

Furthermore, the function foot_rank shows the final rank table and the plot with the predicted points

foot_rank(fit1, italy_2000_2002) # rank league reconstruction

In order to analyze the possible outcomes of the predicted matches, the function foot_prob provides a table containing the home win, draw and away win probabilities for the out-of-sample matches

foot_prob(fit1, italy_2000_2002) # out-of-sample posterior pred. probabilities

For more and more technical details and references, see the vignette!

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.