Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (20.4%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
An R package for many football models
Basic Info
- Host: GitHub
- Owner: LeoEgidi
- Language: R
- Default Branch: master
- Size: 25 MB
Statistics
- Stars: 45
- Watchers: 3
- Forks: 8
- Open Issues: 4
- Releases: 0
Created over 6 years ago
· Last pushed 11 months ago
Metadata Files
Readme
Changelog
README.Rmd
---
output: github_document
---
```{r}
#| echo: false
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# footBayes
[](https://cran.r-project.org/package=footBayes)

[](https://github.com/LeoEgidi/footBayes/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/LeoEgidi/footBayes)
[](https://CRAN.R-project.org/package=footBayes)
The goal of `footBayes` is to propose a complete workflow to:
- Fit the most well-known football models, including the double Poisson, bivariate Poisson, Skellam, and Student‑t distributions. It supports both maximum likelihood estimation (MLE) and Bayesian inference. For Bayesian methods, it incorporates several techniques: MCMC sampling with Hamiltonian Monte Carlo, variational inference using either the Pathfinder algorithm or Automatic Differentiation Variational Inference (ADVI), and the Laplace approximation.
- Visualize the teams' abilities, the model checks, the rank-league reconstruction;
- Predict out-of-sample matches.
## Installation
Starting with version **2.0.0**, `footBayes` package requires installing the R package [`cmdstanr`](https://mc-stan.org/cmdstanr/) (not available on CRAN) and the command-line interface to Stan: [`CmdStan`](https://mc-stan.org/users/interfaces/cmdstan.html).
For a step-by-step installation, please follow the instructions provided in [Getting started with CmdStanR](https://mc-stan.org/cmdstanr/articles/cmdstanr.html).
You can install the released version of `footBayes` from CRAN with:
``` r
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:
```{r gh-installation, eval = FALSE}
# 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:
```{r load, message=FALSE}
library(footBayes)
library(dplyr)
```
```{r fit1, results='hide', message=FALSE}
# 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
```{r summary}
print(fit1, pars = c("att", "def"))
```
To visually investigate the attack and defense effects, we
can use the `foot_abilities` function
```{r abilities}
foot_abilities(fit1, italy_2000_2002) # teams abilities
```
To check the adequacy of the Bayesian model the function `pp_foot` provides posterior predictive plots
```{r pp_foot}
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
```{r pp_foot}
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
```{r pp_foot}
foot_prob(fit1, italy_2000_2002) # out-of-sample posterior pred. probabilities
```
For more and more technical details and references, see the vignette!
Owner
- Name: Leonardo Egidi
- Login: LeoEgidi
- Kind: user
- Repositories: 14
- Profile: https://github.com/LeoEgidi
Assistant Professor, Statistics Personal website: www.leonardoegidi.com
GitHub Events
Total
- Watch event: 6
- Issue comment event: 1
- Member event: 1
- Push event: 72
- Pull request event: 12
- Fork event: 1
- Create event: 1
Last Year
- Watch event: 6
- Issue comment event: 1
- Member event: 1
- Push event: 72
- Pull request event: 12
- Fork event: 1
- Create event: 1
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Leonardo Egidi | l****i@u****t | 498 |
| LeoEgidi | l****i@h****t | 40 |
| Vasilis-Palaskas | v****4@g****m | 3 |
Committer Domains (Top 20 + Academic)
hotmail.it: 1
units.it: 1
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 4
- Total pull requests: 7
- Average time to close issues: N/A
- Average time to close pull requests: 18 days
- Total issue authors: 4
- Total pull request authors: 2
- Average comments per issue: 1.5
- Average comments per pull request: 0.14
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 6
- Average time to close issues: N/A
- Average time to close pull requests: 6 days
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.17
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- zpf527 (1)
- tommyod (1)
- schmalte04 (1)
- fine-lemur (1)
Pull Request Authors
- RoMaD-96 (10)
- Vasilis-Palaskas (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 661 last-month
- Total docker downloads: 41,971
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 4
- Total maintainers: 1
cran.r-project.org: footBayes
Fitting Bayesian and MLE Football Models
- Homepage: https://github.com/leoegidi/footbayes
- Documentation: http://cran.r-project.org/web/packages/footBayes/footBayes.pdf
- License: GPL-2
-
Latest release: 2.0.0
published about 1 year ago
Rankings
Stargazers count: 9.4%
Forks count: 10.1%
Average: 29.4%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 62.3%
Maintainers (1)
Last synced:
11 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.1.0 depends
- arm * imports
- bayesplot * imports
- dplyr * imports
- extraDistr * imports
- ggplot2 * imports
- magrittr * imports
- matrixStats * imports
- metRology * imports
- numDeriv * imports
- parallel * imports
- reshape2 * imports
- rstan >= 2.18.1 imports
- tidyverse * imports
- engsoccerdata * suggests
- knitr >= 1.37 suggests
- loo * suggests
- rmarkdown >= 2.10 suggests
- testthat * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite