-
Notifications
You must be signed in to change notification settings - Fork 9
/
README.Rmd
64 lines (42 loc) · 1.85 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# footBayes
The goal of ```footBayes``` is to propose a complete workflow to:
- fit the most well-known football models: double Poisson, bivariate Poisson, Skellam, student-t, according to both maximum likelihood and Bayesian methods (+ Hamiltonian Monte Carlo engine);
- visualize the teams' abilities, the model checks, the rank-league reconstruction;
- predict out-of-sample matches.
## Installation
Alternatively to CRAN, you can safely install ```footBayes``` 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 example, eval = FALSE}
library(footBayes)
require(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")
fit1 <- stan_foot(data = italy_2000_2002,
model="double_pois",
predict = 36) # double poisson fit (predict last 4 match-days)
foot_abilities(fit1, italy_2000_2002) # teams abilities
pp_foot(italy_2000_2002, fit1) # pp checks
foot_rank(italy_2000_2002, fit1) # rank league reconstruction
foot_prob(fit1, italy_2000_2002) # out-of-sample posterior pred. probabilities
```
For more and more technical details and references, see the vignette!