Posterior predictive checks for football models
Description
The function provides posterior predictive plots to check the adequacy of the Bayesian models as
returned by the stan_foot function.
Usage
pp_foot(object, data, type = "aggregated", coverage = 0.95)Arguments
object |
An object either of class |
data |
A data frame containing match data with columns:
If the model was fitted with |
type |
Type of plots, one among |
coverage |
Argument to specify the width \(1-\alpha\) of posterior probability intervals. Default is 0.95. |
Details
Posterior predictive plots: when "aggregated" (default) is selected, the function
returns a frequency plot for some pre-selected goal-difference values,
along with their correspondent Bayesian p-values, computed as
\(Pr(y_{rep} \ge y)|y)\), where \(y_{rep}\) is a data replication from the
posterior predictive distribution (more details in Gelman et al., 2013).
Bayesian p-values very close to 0 or 1 could exhibit
possible model misfits.
When "matches" is selected an ordered-frequency plot for all the
goal-differences in the considered matches is provided, along with the
empirical Bayesian coverage at level \(1-\alpha\).
Value
A list with elements:
pp_plot: Aggplotobject for the selectedtypeof plot.pp_table: A data frame of summary statistics:For
"aggregated": Goal differences and their Bayesian p-values.For
"matches": Nominal1-alphaand observed empirical Bayesian coverage.
References
Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian data analysis. CRC press.
Examples
## Not run:
if (instantiate::stan_cmdstan_exists()) {
library(dplyr)
data("italy")
italy_2000 <- italy %>%
dplyr::select(Season, home, visitor, hgoal, vgoal) %>%
dplyr::filter(Season == "2000")
colnames(italy_2000) <- c("periods", "home_team", "away_team", "home_goals", "away_goals")
fit <- stan_foot(italy_2000, "double_pois", iter_sampling = 200)
pp_foot(fit, italy_2000)
}
## End(Not run)