In Dixon, Coles (1997), they have used the maximum likelihood estimation for the two modified independent Poisson models in (4.3) to model the scores in soccer.
I am trying to use R in order to "reproduce" the alpha and beta as well as the home effect parameters (pg. 274, Table 4) without using any packages (using the usual independent Poisson models are fine too). I have tried using bivpois package but I am not sure on how to modify its parameters.
I would greatly appreciate it if anyone can help me with the R code to model the data - Scores from the home and away team for Season 2012/13 in English Premier League. So, basically i need help in coding of equation 4.3 or 4.5 using the optim function in R.
Density for poisson distribution (Only 1 independent Poisson model)
poiprob = function (x) {
(((alpha*beta*home)^x)*exp(-(alpha*beta*home))/(factorial(x)))
}
as.matrix(poiprob(x=mydata$HS[1]))
Normal Poisson Likelihood Function
ll.poisson <- function(par, y) {
(alpha*beta*home) <- exp(par)
out <- sum(y * log((alpha*beta*home))) - length(y) * (alpha*beta*home)
return(out)
}
Optimisation to find the appropriate estimates for alpha and beta.
opt <- optim(par = 2, fn = ll.poisson, method = "BFGS", control = list(fnscale = -1),
y = mydata$HS)$par
mle <- exp(opt)
I encountered error in finding the estimates for the 3 parameters, alpha, beta and home effect. Can anyone advise me a way to improve the codes?
Data is in the form,
HS AS Home Away
1 2 1 Arsenal Aston Villa
2 1 2 Arsenal Chelsea
3 0 0 Arsenal Everton
.
.
.
378 2 2 Wigan Athletic Tottenham Hotspur
379 1 2 Wigan Athletic West Bromwich …
380 2 1 Wigan Athletic West Ham United