# A Bayesian In-Play Prediction Model for Association Football Outcomes
## 3 Bayesian Inference
### The Posterior Distributions  
Bayesian inferences are conditional on the actual data and analyses directly extrapolate from the posterior distribution, which provides prior and current in-match information on the parameters. When the scoring information from start to time \(T\) is observed, the posterior distribution of \(\theta=(\theta_{1},\theta_{2})\) is  
\[\pi(\theta|Z)=\frac{\pi(\theta)f(Z,\theta)}{\int\pi(\theta)f(Z,\theta)d\theta} \propto\pi(\theta)f(Z,\theta). \tag{11}\]If total goals are more than 0, the posterior distribution is in proportion to  
\[ \begin{split}\pi(\theta|Z)&\propto e^{-(a\frac{\phi}{ \phi}\sum\limits_{t=1/90}^{T/90}\rho(t)\tau_{xy}(t)+\omega_{1})\theta_{1}-( \frac{1}{\phi}\sum\limits_{t=1/90}^{T/90}\rho(t)\kappa_{xy}(t)+\omega_{2}) \theta_{2}}\cdot\theta_{1}^{r_{1}-1}\theta_{2}^{r_{2}-1}\\ &\times\prod_{l=1}^{m}(a\rho(t_{l})\tau_{xy}(t_{l})\theta_{1}+ \zeta_{1}t_{l})^{1-J_{l}}(\rho(t_{l})\kappa_{xy}(t_{l})\theta_{2}+\zeta_{2}t_{ l})^{J_{l}};\end{split}  \tag{12}\]  
if there are no goals, namely, \(X(T)=Y(T)=0\), the posterior distribution is in proportion to  
\[ \begin{split}\pi(\theta|Z)&\propto e^{-(a\frac{ \phi}{\phi}\sum\limits_{t=1/90}^{T/90}\rho(t)\tau_{xy}(t)+\omega_{1})\theta_{1} -(\frac{1}{\phi}\sum\limits_{t=1/90}^{T/90}\rho(t)\kappa_{xy}(t)+\omega_{2}) \theta_{2}}\cdot\theta_{1}^{r_{1}-1}\theta_{2}^{r_{2}-1}\\ &=e^{-(a\frac{\phi}{\phi}\sum\limits_{t=1/90}^{T/90}\rho(t)\tau _{xy}(t)+\omega_{1})\theta_{1}-(\frac{1}{\phi}\sum\limits_{t=1/90}^{T/90}\rho( t)\kappa_{xy}(t)+\omega_{2})\theta_{2}}\cdot\theta_{1}^{r_{1}+X(T)-1}\theta_{2}^{r_{2}+Y(T )-1}\end{split}  \tag{13}\]  
It will be noted that when there are no goals, the posterior mean can be obtained in a concise form. However, when the number of total goals is more than zero, the posterior mean is obtained in a closed, albeit relatively complex form. In addition, when further Bayesian inference is performed, it is still necessary to use the Metropolis algorithm to generate samples from the posterior distribution. However, if we let \(\xi_{1}=\xi_{2}=0\), \(f(Z,\theta)\) is in proportion to the probability mass function of Poisson distribution, and then the posterior distribution will be  
\[\pi(\theta|Z)\propto e^{-(a\frac{\phi}{\phi}\sum\limits_{t=1/90}^{T/90}\rho(t )\tau_{xy}(t)+\omega_{1})\theta_{1}-(\frac{1}{\phi}\sum\limits_{t=1/90}^{T/90 }\rho(t)\kappa_{xy}(t)+\omega_{2})\theta_{2}}\cdot\theta_{1}^{r_{1}+X(T)-1} \theta_{2}^{r_{2}+Y(T)-1} \tag{14}\]  
which is Gamma distribution. Namely, the poster distributions of \(\theta_{1}\) and \(\theta_{2}\) are  
\[\theta_{1}|Z\sim Gamma(\frac{a}{90}\sum\limits_{t=1/90}^{T/90}\rho(t)\tau_{ xy}(t)+\omega_{1},r_{1}+X(T)) \tag{15}\]  
and  
\[\theta_{2}|Z\sim Gamma(\frac{1}{90}\sum\limits_{t=1/90}^{T/90}\rho(t)\kappa_{ xy}(t)+\omega_{2},r_{2}+Y(T)). \tag{16}\]  
The estimates of parameters \(\xi_{1}\) and \(\xi_{2}\) are fairly small, which are usually less than 0.5. Take \(\xi=0.5\) for example, \(\xi\) makes \(\frac{1}{2}\xi t^{2}\) contributions to the expected number of goals, where \(t\in(0,1)\). For instance, when we have observed in-match information of the first half, if we did not consider the effect of \(t\), the time of left to play, we would merely underestimate the expected number of goals by 0.06. In addition, empirical study shows that if the time left to play is not considered in the likelihood function, it has little effect on the final prediction accuracy. When total goals are more than 0, for likelihood function \(f(Z,\theta)\), we use the following approximation  
\[f(Z,\theta)\propto e^{-\frac{1}{\phi}\sum\limits_{t=1/90}^{T/90}(\lambda(t)+ \mu(t))}\prod_{l=1}^{m}\lambda(t_{l})^{1-J_{l}}\mu(t_{l})^{J_{l}}. \tag{17}\]  
So no matter whether there are goals during \((0,T]\), the posterior distributions of \(\theta_{1}\) and \(\theta_{2}\) are shown in Equations (15) and (16) respectively. In this paper, we use posterior means as estimations of teams' strengths calibrated with in-match information.