View source: R/foot_abilities.R
foot_abilities | R Documentation |
Depicts teams' abilities either from the Stan models fitted via the stan_foot
function
or from MLE models fitted via the mle_foot
function.
foot_abilities(object, data, type = "both", teams = NULL)
object |
An object either of class |
data |
A data frame containing match data with columns:
|
type |
Type of ability in Poisson models: one among |
teams |
An optional character vector specifying team names to include. If |
A ggplot
object showing each selected team’s ability estimates:
For static Bayesian or MLE fits, horizontal error bars (95% intervals) and point estimates.
For dynamic Bayesian fits, ribbon and line plots over periods
.
Leonardo Egidi legidi@units.it and Roberto Macrì Demartino roberto.macridemartino@deams.units.it.
## Not run:
if (instantiate::stan_cmdstan_exists()) {
library(dplyr)
data("italy")
italy <- as_tibble(italy)
### no dynamics, no prediction
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")
fit1 <- stan_foot(
data = italy_2000_2002,
model = "double_pois"
) # double poisson
fit2 <- stan_foot(
data = italy_2000_2002,
model = "biv_pois"
) # bivariate poisson
fit3 <- stan_foot(
data = italy_2000_2002,
model = "skellam"
) # skellam
fit4 <- stan_foot(
data = italy_2000_2002,
model = "student_t"
) # student_t
foot_abilities(fit1, italy_2000_2002)
foot_abilities(fit2, italy_2000_2002)
foot_abilities(fit3, italy_2000_2002)
foot_abilities(fit4, italy_2000_2002)
### seasonal dynamics, predict the last season
fit5 <- stan_foot(
data = italy_2000_2002,
model = "biv_pois",
predict = 180,
dynamic_type = "seasonal"
) # bivariate poisson
foot_abilities(fit5, italy_2000_2002)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.