A Bayesian Approach to Predict the Number of Goals in Hockey

In this paper, we use a Bayesian methodology to analyze the outcome of a hockey game using different sources of information, such as points in previous games, home advantage, and specialists’ opinions. Two different models to predict the number of goals are considered, taking into account that it is the nature of hockey that goals are infrequent and rarely exceed six per team per game. A Bayesian predictive density to predict the number of the goals using each model will be used and the possible winner of the game will be predicted. The corresponding prediction error for each model will be addressed.


Introduction
Finding ways of predicting the outcome in different sport games from past and current data is an attractive problem for different people, ranging from the sports teams' coaches to gambling agencies to fans of that sport.There is no doubt that statistical tools are needed to construct an effective and accurate model to predict the outcome of sporting events.In the last decades, predicting match results has attracted much attention from researchers using new methods of statistics, data mining and machine learning, especially in popular sports such as football, basketball, baseball and soccer.
Ice hockey is a popular sport especially in the US and Canada for which there exists a rich dataset available at www.nhl.com.Several publications have appeared in recent years documenting different statistical analysis of the hockey data.Gramacy et al. [1] studied individual contributions of team members using regularized logistic regression.Sadeghkhani and Ahmed [2] estimated the density of scoring time in a hockey game using prior information such as a team's ranking in the previous season and experts' opinions.Suzuki et al. [3] proposed a Bayesian approach in predicting the match outcomes in the 2006 World Cup.
However, to the authors' best knowledge, very few publications currently available in the literature address the issue of Bayesian density estimation of number of the goals.This paper proposes a unique method to estimate the density of number of the goals.We also consider the points in the previous games, away and home factors, and specialists' opinions to improve our predictions.
The remainder of the paper is organized as follows: In Section 2, we provide definitions and preliminary remarks about two assumptions to model the number of goals in a hockey game.Section 3 discusses how to find Bayesian predictive density estimators for each model.Section 4 addresses how one can enter other factors such as home bonus, away malus, experts' opinions in detail.In Section 5, we study an application of the proposed methods in predicting the number of goals as well as the result of the game.Finally, we make some concluding remarks in Section 6.

Problem Set-Up and Different Models
Poisson distribution has been used in the context of count data, but the fact that the dispersion index (the ratio of variance to mean) equals one is a big concern in practice.Conway and Maxwell [4] introduced the Conway-Maxwell-Poisson (COM-P) distribution, which, similar to the Poisson distribution, belongs to the exponential family of distributions and, therefore, the Bayesian analysis (because of the conjugate prior) of number of events becomes more computationally tractable.
Kadane et al. [5] studied a necessary and sufficient condition on the hyperparameters of the conjugate family for the prior to be proper and discussed methods of sampling from the conjugate distribution.
The COM-P distribution processes an extra parameter and was originally developed as a solution of handling a queuing system with state-dependant arrivals.It has has been used widely in the models that that have over-dispersion or under-dispersion, i.e., the mean is smaller or larger than variance, respectively.For more information, see Shmueli et al. [6].
A random variable (rv for short) has the COM-P(λ, r) distribution if it has the probability mass function (pmf) in the form of where It is easy to see the Poisson distribution, Po(λ), obtained when r = 1.Furthermore, the density in (1) belongs to exponential family and values of r > 1 and r < 1 are equivalent to under-and over-dispersion each.When λ ∈ (0, 1), tending r → inf gives Bernoulli with parameter λ while the geometric distribution corresponds to limiting r → 0 with pmf of P(X = x | λ) = λ x (1 − λ), for x = 0, 1, . ... Imoto [7] generalized the COM-P to a distribution which has a larger tail and embraces the negative binomial distribution and applicable to the excess zeros model as well.

Bayesian Prior and Posterior Predictive Density Estimations
As can be seen in the literature, gamma distribution is being used as conjugate prior for a Poisson distribution.Suppose ).The marginal distribution of X, known as a prior predictive density estimator, and posterior predictive density estimator are negative binomial distribution.Rv X ∼ NB(r, p) has the pmf while the posterior predictive density of future rv.Y, Proof.The prior predictive in (3) is the marginal distribution of X and can be found as follows: Equation ( 4) can be obtained similarly from and the posterior density of λ based on In the COM-P model, Equation ( 1), Kadane et al. [5] used the extended bivariate gamma distribution denoted by EBG(a, b, c), and given by where the normalization constant in (5), is given by and a > 0, b > 0 and c > 0 needs to satisfy the following condition so that κ −1 (a, b, c) becomes finite: Next lemma, similarly to Lemma 1, provides the predictive distributions.1), for i = 1, . . ., n, and π(λ, r | a, b, c) presented in (5), then: 1. the posterior has the same distribution to (5) , and c * = c + n. 2. the prior predictive density (marginal density of X) is given by

the posterior predictive density of future rv Y, P(
Proof.The proof is straightforward and analogous to the proof of Lemma 1 and has therefore been omitted.

Modelling Number of Goals Using Prior Elicitation Method
In this section, we make two different assumptions: (I) let us assume the number of goals scored by each team is a Poisson rv and (II) it has COM-P.In addition, suppose that A is a team playing home and B is a team playing away and hence, X AB is the number of goals scored by team A to team B and X BA , vice-versa.

Assumption I: Po Distribution for Modelling Number of Goals
Assume that X AB and X BA , are independently distributed as follows: where λ AB can be interpreted as the mean number of goals team A scores against team B and λ BA is the number of goals team B scores against team A in a future game.As discussed earlier, one can use conjugate prior π(λ AB ) (for home) as a Gam(α, β), where the jeffreys non-informative prior AB is its special case.Here, we are interested in employing experts' opinions about the upcoming match's score.This is called prior elicitation and can be determined by π e (•): where x i AB , i = 1, 2, . . ., s, is the i-th expert's opinion about number of goals that home team A will score against away team B in the future game.Choosing d = 0 returns the π(•) as a prior and ignores the specialists' opinion factor.Analogously, we can set prior of λ BA in the same manner.
We have used the specialists to improve our beliefs about λ AB (or λ BA ), but we can also benefit from other sources of information, such as previous data.Since usually (not necessarily) the number of goals is larger when team plays home and smaller when team plays away, we can use the model home-bonus factor h, and away or visiting-malus factor v. Alternatively, one can consider the teams' points as well.The mean of number of goals A scores versus team B is directly related to h and points obtained by team A, namely Q A (in the previous games or last season), and has an indirect relationship with a and points obtained by team B, Q B .Consequently, we can update prior density in (9) (for both λ AB and λ BA ) as follows: Making use of Equations ( 10) and (11), along with Lemma 1, gives the prior and posterior predictive density estimators for the number of goals team A scores to team B, which are, respectively, given by and where x i A is the number of goals team A has scored in the previous season (or prior to the upcoming game) when played at home versus opponents and QE = ∑ n AB 1 Q E i /n AB and Q E i 's are (all) opponents' points in previous season (or prior to the upcoming game) who faces team A and n AB is the number of games team A host team B. Similarly, for the number of goals, team B scores in the home of team A, we have where x i B is the number of goals team B has scored in the previous season (or up to upcoming game) when played on the way versus opponents and QD = ∑ n BA 1 Q D i /n BA and Q D i 's are (all) opponents' points in previous season (or prior to the upcoming match) who hosted team B.

Assumption II: COM − P Model of Number of Goals
A question that may arise is, "What if the distributions of the number of goals do not obey a Poisson distribution?"In this assumption we contemplate the COM-P(λ, r) distribution given in (1) as a distribution of the number of goals.Therefore, X AB and X BA are independently distributed as follows: We use EBG(a, b, c) in (5) as a conjugate prior.Note that for instance, the conditional distribution , where Bet is a beta distribution.Similar to assumption (I), the corresponding prior elicitation can be defined as follows: which is the EBG(a AB , b AB , c AB ), with where n AB is number of goals scored in a game where team A is at home, hosting teams similar to team B when they were on the road.x i AB , i = 1, 2, . . ., s, x i AB , i = 1, 2, . . ., n AB are as defined in assumption (I).This can be done similarly to obtain π e (λ BA , r BA ), log(x i BA !) + b, and c BA = c + n BA + s d, correspondingly.
Finally, we can pose the other additional information home-bonus factor h, away-malus factor v, points Q A and, Q B into our prior yielding the joint distribution (λ AB , r AB ) and (λ BA , r BA ) obtained from Using ( 18) and ( 19), along with Lemma 2, result in obtaining the prior predictive density estimation of the number of goals team A scores against team B as follows: Furthermore, the posterior predictive density of the number of goals team A scores against team B is as follows: Equations ( 20) and ( 21) hold for number of goals teams B scores versus team A by replacing a AB , b AB , with a BA , b BA , respectively.

Example of Predicting the Scores and Results
This section addresses prediction results based on our models, as attained in the previous section.For a given match team where A hosts team B, outcomes of that match under the format win, draw and loss can be predicted via the number of goals scored by the two teams, A and B. Let the probabilities associated with win, draw and loss of team A from the predictive distributions versus team B, denoted by π w , π d and π l .So we can write π w = P(X AB > Let us suppose that we are interested in predicting the match outcome of A: Edmonton Oilers (home) vs B: Arizona Coyotes (away).Data for the season 2017/18 plus current season 2018/19 until the date of writing this manuscript on 29 January 2019 available at nhl.com has been used.In order to use experts' opinions, we have asked 5 specialists to give their opinion about the upcoming match result, x i AB and x i BA as follows: Moreover, the number of goals the Edmonton Oilers scored versus teams which had similar performance to the Arizona Coyotes when playing as a visitor, points per game, and the number of goals Arizona scored versus the teams had similar performance to Edmonton when playing at home (we asked specialists about those teams) are given in Table 1 .
Assumption I: Gam(0.5, 8) is considered for the prior distribution (since in practice the mean of scores by each team is about 4 goals) along with d = 1 as in ( 9).
(a) Prior predictive density estimator corresponds to no matches having been played and we do not have any source of information but experts' opinions about the upcoming game, Edmonton Oilers vs Arizona Coyotes.Making use of Equations ( 12) and (14) yield X AB ∼ NB(17.5, 0.806), X BA ∼ NB(11.5, 0.86) , which correspond to the probabilities below in Table 2. Probability that next match draws 0.12 (b) We consider the posterior predictive densities using Equations ( 13) and ( 15) respectively.Therefore, we have X AB ∼ NB(51.5, 0.924), X BA ∼ NB(34.5, 0.90) . ( In other words, making use of data from season 2017/18 up to current date and specialists' opinions, we are expecting Edmonton Oilers will score 3.25923, while Arizona Coyotes scores 4.69523.Table 3 and Figure 1 illustrate the result.The most probable result is 4-3, in favor of Edmonton.Without using experts' opinions, i.e., d = 0, we have X AB ∼ NB(34.5, 0.96) and X BA ∼ NB(23.5, 0.9414), which corresponds to π w = 0.37, π l = 0.35 and π d = 0.25, respectively.
Assumption II: Let us take a = b = c = 1, d = 1 and r = 0.9.These choices result in having the expectation of λ equals 3.88 based on the prior distribution in (5).By applying (21), the posterior predictive densities of the number of the goals in the upcoming match Edmonton versus Arizona, along with corresponding plot, are given in Table 4 and Figure 2. Also from Table 4, we are expecting to see 1.96 for Edmonton and 2.6 goals for Arizona.Table 5 shows the winning probabilities and one can predict that in the upcoming match, based on assumption II, Arizona will win the match in the Edmonton's home, and most probable result is 3-2.

Prediction Errors
Prediction errors (pe's) of our posterior predictive distributions in the two assumptions, when the specialists' opinions matter, (namely q1 (x AB ) and q2 (x AB ) respectively) are evaluated by measuring the Kullback-Leibler distance as below.
where q λ AB (x AB ) is the Poisson distribution in (8) and qi (x AB ) for i = 1, 2 are given in ( 13) and ( 21), respectively.This can be repeated for q1 (x BA ) and q2 (x BA ) as well.
According to Table 1, one needs to calculate the distance between Po(5) and NB(51.5, 0.924) regarding number of goals team A scores against team B and the distance between Po(3) and NB(34.5, 0.90) regarding number of goals team B scores A in Assumption I.There we have pe( q1,AB ) = 0.026 and pe( q1,BA ) = 0.033.In contrast, if we follow Assumption II based on Table 4, the prediction errors become pe( q2,AB ) = 0.18 and pe( q2,BA ) = 0.046, respectively.

Simulation Study
We consider a small simulation study based on a sample of size of 1000, in order to investigate the proposed posterior density estimators regarding number of goals team B scores against team A in Section 5. Figure 3 depicts the assumed underlying model Po (Assumption I) and COM-P (Assumption II) along with their corresponding posterior predictive densities.It can be seen that model assumption I and its posterior predictive density estimator performs better for the number of goals.

Conclusions
In summation, we have proposed Bayesian predictive density estimators for the number of goals in a hockey match and consequently predicting the winner of the game.We considered two different assumptions and furthermore we considered points in previous games, away and home factors, and specialists' opinions to improve our predictions.Assumption I, is based on that the underlying model, i.e., the number of goals in hockey, follows the Poisson distributions, and Assumption II considers the COM-P.However, based on prediction errors, it is easier to assume Assumption I. Eventually, the predictors based on either Assumption I or II, confirm that Edmonton (home team) will win game the next match versus Arizona (away team) by a difference of one goal with 48 and 55 percent, respectively.
h = Mean of goals scored by team A at home versus team B in previous matches Mean of goals by all the team in hosting their opponents , v = Mean of goals scored by team B away versus team A in previous matches Mean of goals by all the team on the way with their opponents .

Figure 3 .
Figure 3. Simulation study of based on sample of size 1000, under model Assumption I (above) and Assumption II (below).

Table 1 .
(Left)Table of the number of goals the Edmonton Oilers scored in the 2018/19 season (up to 29 January) versus the Arizona Coyotes as well as teams with the similar abilities to the Arizona Coyotes, playing away.(Right) Table of number of goals the Arizona Coyotes scored in the 2017/18 and 2018/19 season (up to 29 January) scored versus the Edmonton Oilers as well as teams with similar abilities to the Edmonton Oilers when playing at home.

Table 2 .
Winning probabilities of future upcoming match: Edmonton Oilers vs Arizona Coyotes, based on specialists' opinion.

Table 3 .
Winning probabilities of future upcoming match: Edmonton Oilers vs Arizona Coyotes based on specialists' opinion and the dataset for season 2017/18 and current season up to 29 January 2019.π w Probability that Edmonton Oilers wins the next match 0.48 π l Pmf of number of Edmonton Oilers vs Arizona Coyotes from (22) based on specialists' opinion and dataset 2017/18 and 2018/19 season (up to 29 January).

Table 4 .
Posterior predictive densities of number of goals scored by Edmonton versus Arizona.

Table 5 .
Winning probabilities of future upcoming match: Edmonton Oilers vs Arizona Coyotes based on specialists' opinion and dataset season 2017/18 and current season up to 29 January 2019.Pmf of number of Edmonton Oilers vs Arizona Coyotes from Table 4 based on specialists' opinion and dataset season 2017/18 and 2018/19 season (up to 29 January).