Bayesian Hierarchical
Bayesian Hierarchical
net/publication/46527004
CITATIONS READS
141 4,337
2 authors:
All content following this page was uploaded by Gianluca Baio on 26 May 2014.
Abstract
The problem of modelling football data has become increasingly pop-
ular in the last few years and many different models have been proposed
with the aim of estimating the characteristics that bring a team to lose or
win a game, or to predict the score of a particular match. We propose a
Bayesian hierarchical model to address both these aims and test its predic-
tive strength on data about the Italian Serie A championship 1991-1992.
To overcome the issue of overshrinkage produced by the Bayesian hierar-
chical model, we specify a more complex mixture model that results in
better fit to the observed data. We test its performance using an example
about the Italian Serie A championship 2007-2008.
Keywords: Bayesian hierarchical models; overshrinkage; Football data;
bivariate Poisson distribution.
1 Introduction
Statistical modelling of sport data is a popular topic and much research has been
produced to this aim, also in reference to football. From the statistical point of
view, the task is stimulating because it raises some interesting issues. One such
∗ To whom correspondence should be sent. However, this work is the result of equal partici-
pation of both authors in all the aspects of preparation, analysis and writing of the manuscript.
1
matter is related to the distributional form associated with the number of goals
scored in a single game by the two opponents.
Although the Binomial or Negative Binomial have been proposed in the late
1970s (Pollard et al. 1977), the Poisson distribution has been widely accepted
as a suitable model for these quantities; in particular, a simplifying assumption
often used is that of independence between the goals scored by the home and
the away team. For instance, Maher (1982) used a model with two independent
Poisson variables where the relevant parameters are constructed as the product
of the strength in the attack for one team and the weakness in defense for the
other.
Despite that, some authors have shown empirical, although relatively low,
levels of correlation between the two quantities (Lee 1997, Karlis & Ntzoufras
2000). Consequently, the use of more sophisticated models have been proposed,
for instance by Dixon & Coles (1997), who applied a correction factor to the
independent Poisson model to improve the performance in terms of prediction.
More recently, Karlis & Ntzoufras (2000, 2003) advocated the use of a bivariate
Poisson distribution that has a more complicated formulation for the likelihood
function, and includes an additional parameter explicitly accounting for the
covariance between the goals scored by the two competing teams. They specify
the model in a frequentist framework (although extensions using the Bayesian
approach have been described by Tsionas 2001), and their main purpose is the
estimation of the effects used to explain the number of goals scored.
We propose in this paper a Bayesian herarchical model for the number of
goals scored by the two teams in each match. Hierarchical models are widely
used in many different fields as they are a natural way of taking into account
relations between variables, by assuming a common distribution for a set of
relevant parameters, thought to underlay the outcomes of interest (Congdon
2003).
Within the Bayesian framework, which naturally accommodates hierarchical
models (Bernardo & Smith 1999), there is no need of the bivariate Poisson
modelling. We show here that assuming two conditionally independent Poisson
variables for the number of goals scored, correlation is taken into account, since
the observable variables are mixed at an upper level. Moreover, as we are framed
in a Bayesian context, prediction of a new game under the model is naturally
accommodated by means the posterior predictive distribution.
The paper is structured as follow: first we describe in § 2 the model and the
data used; § 3 describes the results in terms of parameter estimations as well as
prediction of a new outcome. In § 4 we deal with the problem of overshrinkage
and present a possible solution using a mixture model. Finally § 5 presents some
issues and some possible extension that can be material for future work and in
§ 6 we include the WinBUGS code for our analysis.
2 The model
In order to allow direct comparison with Karlis & Ntzoufras (2003), we first
consider the Italian Serie A for the season 1991-1992. The league is made by a
total of T = 18 teams, playing each other twice in a season (one at home and
one away). We indicate the number of goals scored by the home and by the
away team in the g−th game of the season (g = 1, . . . , G = 306) as yg1 and yg2
2
respectively.
The vector of observed counts y = (yg1 , yg2 ) is modelled as independent
Poisson:
where the parameters θ = (θg1 , θg2 ) represent the scoring intensity in the g-th
game for the team playing at home (j = 1) and away (j = 2), respectively.
We model these parameters according to a formulation that has been used
widely in the statistical literature (see Karlis & Ntzoufras 2003 and the reference
therein), assuming a log-linear random effect model:
Poisson-logNormal models have been discussed and widely used in the literature
— see for instance Aitchinson & Ho (1989), Chib & Winkelman (2001) and
Tunaru (2002).
The parameter home represents the advantage for the team hosting the game
and we assume that this effect is constant for all the teams and throughout the
season. In addition, the scoring intensity is determined jointly by the attack
and defense ability of the two teams involved, represented by the parameters
att and def , respectively. The nested indexes h(g), a(g) = 1, . . . , T identify the
team that is playing at home (away) in the g-th game of the season.
The data structure for the model is presented in Table 1 and consist of the
name and code of the teams, and the number of goals scored for each game
of the season. As is possible to see, the indexes h(g) and a(g) are uniquely
associated with one of the 18 teams. For example, in Table 1 Sampdoria are
always associated with the index 16, whether they play away, as for a(4), or at
home, as for h(303).
In line with the Bayesian approach, we have to specify some suitable prior
distributions for all the random parameters in our model. The variable home
is modelled as a fixed effect, assuming a standard flat prior distribution (notice
that we use here the typical notation to describe the Normal distribution in
terms of the mean and the precision):
3
Conversely, for each t = 1, . . . , T , the team-specific effects are modelled as ex-
changeable from a common distribution:
θg1 θg2
yg1 yg2
4
3 Results
According to the Bayesian approach, the objective of our modelling is two-fold:
first, we wish to estimate the value of the main effects that we used to explain
the scoring rates. This task is accomplished by entering the evidence provided
by the observed results (the vector y) and updating the prior distributions by
means of the Bayes’s theorem using an MCMC-based procedure.
Table 2 shows some summary statistics for the posterior distributions of the
coefficients for the log-linear model describing the scoring intensity.
Similarly to what found in other works, the home effect is positive (the
posterior mean and 95% CI are 0.2124 and [0.1056; 0.3213], respectively). AC
Milan, the league winner in that year, have by far the highest propensity to
score (as suggested by the posterior mean of 0.5226 for the effect att ). The top
three clubs (AC Milan, Juventus and Torino) performed better than any other
club in terms of defence showing the lowest value for the parameter def , while
Ascoli (who were actually relegated), Foggia and Verona showed the highest
propensity to concede goals.
The second — and probably more interesting — objective of the model is
that of prediction. We can use the results derived in the implied posterior
distributions for the vector θ to predict a future occurrence of a similar (ex-
changeable) game. In this case, we produced a vector of 1000 replications for
the posterior predictive distribution of y that we used for the purpose of model
checking.
Figure 2 shows the comparison between the observed results throughout the
season (the black line) and the estimations provided by both the posterior pre-
dictions from our model (in blue) and the bivariate Poisson model of Karlis
& Ntzoufras (2003) (in red). As one can appreciate, for most of the teams
(Atalanta, Foggia, Genoa, Inter, Juventus, AC Milan, Napoli, Parma, Roma,
Sampdoria, Torino and Verona), the Bayesian hierarchical model seem to pro-
5
40 50 40
Ascoli Atalanta Bari
20 20
0 0 0
0 20 40 0 20 40 0 20 40
50 40 50
Cagliari Cremonese Fiorentina
20
0 0 0
0 20 40 0 20 40 0 20 40
50 40 50
Foggia Genoa Inter
20
0 0 0
0 20 40 0 20 40 0 20 40
100 50 100
Juventus Lazio Milan
50 50
0 0 0
0 20 40 0 20 40 0 20 40
100 50 100
Napoli Parma Roma
50 50
0 0 0
0 20 40 0 20 40 0 20 40
50 100 40
Sampdoria Torino Verona
50 20
0 0 0
0 20 40 0 20 40 0 20 40
duce a better fit to the observed results. For a few teams, the red line is closer
to the black one (Cagliari, Cremonese and, marginally, Lazio), while for Ascoli,
Bari and Fiorentina the two estimations are equally poor (with the Bayesian
hierarchical model generally overestimating the final result and the bivariate
Poisson generally underestimating it). In general, it seems that our model per-
forms better than the bivariate Poisson in terms of adapting to the observed
dynamics throughout the season.
6
with the effect of: a) penalising extremely good teams; and b) overestimate the
performance of poor teams.
One possible way to avoid this problem is to introduce a more complicated
structure for the parameters of the model, in order to allow for three different
generating mechanism, one for the top teams, one for the mid-table teams, and
one for the bottom-table teams. Also, in line with Berger (1984), shrinkage can
be limited by modelling the attack and defense parameters using a non central
t (nct) distribution on ν = 4 degrees of freedom instead of the normal of § 2.
Consequently, the model for the likelihood, and the prior specification for
the θgj and for the hyper-parameter home is unchanged, while the other hyper-
parameters are modelled as follows. First we define for each team t two latent
(unobservable) variables grpatt (t) and grpdef (t), which take on the values 1, 2 or
3 identifying the bottom-, mid- or top-table performances in terms of attack (de-
fense). These are given suitable categorical distributions, each depending on a
def def def
vector of prior probabilities πatt = (π1t att att
, π2t att
, π3t ) and π def = (π1t , π2t , π3t ).
We specify minimally informative models for both π att and π def in terms of a
Dirichlet distribution with parameters (1, 1, 1), but obvioulsy one can include
(perhaps subjective) prior information on the vectors π att and πdef to represent
the prior chance that each team is in one of the three categories.
The attack and defense effects are then modelled for each team t as:
att t ∼ nct µatt att
grp(t) , τgrp(t) , ν , def t ∼ nct µdef , τ def
grp(t) grp(t) , ν .
In particular, since the values of grpatt (t) and grpdef (t) are unknown, this for-
mulation essentially amounts to defining a mixture model on the attack and
defense effects:
3
X 3
X
def
att
× nct µatt att
× nct µdef def
att t = πkt k , τk , ν , def t = πkt k , τk , ν .
k=1 k=1
The location and scale of the nct distributions (as suggested, we use ν = 4)
depend on the probability that each team actually belongs in any of the three
categories of grpatt (t) and grpdef (t).
The model for the location and scale parameters of the nct distributions
is specified as follows. If a team have poor performance, then they are likely
to show low (negative) propensity to score, and high (positive) propensity to
concede goals. This can be represented using suitable truncated Normal distri-
butions, such as
µatt
1 ∼ truncNormal(0, 0.001, −3, 0)
µdef
1 ∼ truncNormal(0, 0.001, 0, 3).
µatt
3 ∼ truncNormal(0, 0.001, 0, 3)
µdef
3 ∼ truncNormal(0, 0.001, −3, 0)
Finally, for the average teams we assume that the mean of the attack and defense
effect have independent dispersed Normal distributions
def
µatt att
2 ∼ Normal(0, τ2 ) µ2 ∼ Normal(0, τ2def )
7
(that is, on average, the attack and defense effects are 0, but can take on both
negative or positive values).
For all the groups k = 1, 2, 3, the precisions are modelled using independent
minimally informative Gamma distributions
Figure 3 shows the (average) attack versus defense effects for each of the 20
teams. The positioning of the teams on the plane fits well the observed values of
scored and conceded goals (that are obviously the base upon which the attack
and defense effects are calculated) — recall that good teams are associated with
negative defense effect.
8
0.2
Par
Liv
0.1 Reg Pal
Ata
Cag
Nap
Emp Udi
Gen
Laz
Tor
Sam
0 Cat
Sie
Defense effect
−0.1 Fio
Mil Juv
Rom
−0.2
−0.3
−0.4
Int
−0.5
−0.4 −0.3 −0.2 −0.1 0 0.1 0.2 0.3 0.4
Attack effect
As one can observe, several clusters of teams can be identified in the graph.
Firstly, Inter has the smallest value for the defense effect (in line with the fact
that the number of conceded goals is by far the minimum); Roma, Juventus
and AC Milan perform well defensively (although not as good as Inter) all in
a similar manner, while showing a very good attacking capacity. Fiorentina
and Sampdoria are the best “mid-table” teams (doing slightly better in defense
and in attack, respectively, in comparison with the rest of the teams). Empoli
(who were actually relegated at the end of the campaign) have the poorest
performance in terms of attack. Parma and Livorno have the highest defense
values (that is the worst performances).
Figure 4 shows the posterior prediction of the entire season. As one can
see, for many of the teams the dynamics are quite consistent with the observed
results (see for example Atalanta, Genoa, Juventus, AC Milan, Napoli, Palermo
and Sampdoria). The “extreme” observations are subject to some shrinkage (but
to a much lower extent, as compared to the results from the standard model).
In particular, while the estimation for the top-table teams (Inter and Roma in
particular) is relatively in line with the observed results, the performances of
Parma, Livorno and perhaps Reggina are slightly overestimated.
Table 3 shows the estimated final table in comparison with the one actually
observed. As one can see, despite some differences in the overall number of
points (particularly for the extreme teams), the estimates of the number of
scored and conceded goals are generally very much in line with the observed
results. The distribution of the home effect is characterised by a mean and 95%
credible interval of 0.3578 and [0.2748; 0.4413] respectively.
Finally, Figure 5 shows the posterior probability that each team belongs in
one of the three groups (bottom-, mid- and top-table) — respectively for (a)
the attack, and (b) the defense effects. Again, considering the final standings
showed in Table 3, the results seem reasonable.
9
100 50 50 40
Atalanta Cagliari Catania Empoli
50 20
0 0 0 0
0 20 40 0 20 40 0 20 40 0 20 40
100 50 100 100
Fiorentina Genoa Inter Juventus
50 50 50
0 0 0 0
0 20 40 0 20 40 0 20 40 0 20 40
50 50 100 50
Lazio Livorno Milan Napoli
50
0 0 0 0
0 20 40 0 20 40 0 20 40 0 20 40
50 50 50 100
Palermo Parma Reggina Roma
50
0 0 0 0
0 20 40 0 20 40 0 20 40 0 20 40
100 50 50 100
Sampdoria Siena Torino Udinese
50 50
0 0 0 0
0 20 40 0 20 40 0 20 40 0 20 40
Figure 4: Posterior predictive validation of the mixture model: the black line
represents the observed cumulative points through the season, while the blue
line represents predictions for the Bayesian hierarchical mixture model
Attack effect Defense effect
Udinese Udinese
Torino Torino
Siena Siena
Sampdoria Sampdoria
Roma Roma
Reggina Reggina
Parma Parma
Palermo Palermo
Napoli Napoli
Milan Milan
Livorno Livorno
Lazio Lazio
Juventus Juventus
Inter Inter
Genoa Genoa
Fiorentina Fiorentina
Empoli Empoli
Catania Catania
Cagliari Cagliari
Atalanta Atalanta
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Posterior probability of being a Bottom−, Mid− or Top−table club Posterior probability of being a Bottom−, Mid− or Top−table club
(a) (b)
Figure 5: Posterior probability that each team belongs in one of the three groups
5 Discussion
The model presented in this paper is a simple application of Bayesian hierarchi-
cal modelling. The basic structure presented in § 2 can be easily implemented
and run using standard MCMC algorithms, such as the one provided for WinBUGS
in § 6. The performance of this model is not inferior to the one used by Karlis
& Ntzoufras (2003), which relies on a bivariate Poisson structure and requires
a specific algorithm.
Moreover, the hierarchical model can be easily extended to include a mixture
structure to account for the fact that teams show a different “propensity” to
10
score and concede goals, as represented by the attack and defense effects. In
this case, the model becomes more complex and time consuming, but it can still
be accommodated within standard MCMC algorithms (that we again developed
in WinBUGS).
Sensitivity analysis has been performed on the he choice of the arbitrary
cutoffs of ±3 for the truncated Normal distributions used in the mixture model.
When larger values were chosen, the model was not able to assign the teams
to the three components of mixture, with almost all them being associated
with the second category. This is intuitively due to the fact that when the
truncated Normal distributions have a larger support, their density is too low,
in comparison with the central component. On the other hand, when the cutoff
is too small, then the densities of the extreme components are too high and
therefore none of the teams is assigned to the second category.
One of the limitations of the results produced by the model (rather than of
the model itself) is that, for the sake of simplicity, predictions are obtained in
one batch, that is for all the G games of the season, using the observed results
to estimate the parameters. An alternative, more complex approach would be
to dynamically predict new istances of the games. One possibility would be to
define the hyper-parameters η as “time”-specific, in order to account for periods
of variable form of the teams (including injuries, suspensions, etc.). Moreover,
prior information can be included at various level in the model, perhaps in the
form of expert opinion about the strength of each team.
11
def[t] <- def.star[t] - mean(def.star[])
}
# priors on the random effects
mu.att ~ dnorm(0,0.0001)
mu.def ~ dnorm(0,0.0001)
tau.att ~ dgamma(.01,.01)
tau.def ~ dgamma(.01,.01)
References
Aitchinson, J. & Ho, C. (1989), ‘The multivariate poisson-log normal distribu-
tion’, Biometrika 76, 643–653.
Berger, J. (1984), The robust Bayesian point of view, in J. Kadane, ed., ‘Ro-
bustness of Bayesian analysis’, North Holland, Amsterdam, Netherlands.
Bernardo, J. M. & Smith, A. (1999), Bayesian Theory, John Wiley and Sons,
New York, NY.
12
Chib, S. & Winkelman, R. (2001), ‘Markov Chain Monte Carlo Analysis of Cor-
related Count Data’, Journal of Business and Economic Statistics 4, 428–
435.
Congdon, P. (2003), Applied Bayesian Modelling, John Wiley and Sons, Chich-
ester, UK.
Dixon, M. & Coles, S. (1997), ‘Modelling association football scores and inef-
ficiencies in the football betting market’, Journal of the Royal Statistical
Society C 46, 265–280.
Karlis, D. & Ntzoufras, I. (2000), ‘On modelling soccer data’, Student 3, 229–
244.
Karlis, D. & Ntzoufras, I. (2003), ‘Analysis of sports data by using bivariate
Poisson models’, Journal of the Royal Statistical Society D 52, 381–393.
Lee, A. (1997), ‘Modeling scores in the Premier League: is Manchester United
really the best?’, Chance 10, 15–19.
Lunn, D. (2008), ‘WinBUGS code for the truncated normal distribution’, Docu-
mentation and code available online.
URL: http://www.winbugs-development.org.uk/shared.html
Maher, M. (1982), ‘Modelling association footbal scores’, Statistica Neerlandica
36, 109–118.
Pollard, R., Benjamin, P. & Reep, C. (1977), Sport and the negative binomial
distribution, in S. Ladany & R. Machol, eds, ‘Optimal Strategies in Sports’,
North Holland, New York, NY, pp. 188–195.
Tsionas, E. (2001), ‘Bayesian Multivariate Poisson Regression’, Communica-
tions in Statistics – Theory and Methodology 30(2), 243–255.
Tunaru, R. (2002), ‘Hierarchical bayesian models for multiple count data’, Aus-
trian Journal of Statistics 31, 221–229.
13