Football, an ordinal model
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
On September 19th, flo2speak remarked under a post that his/her experience is that ordinal models had better performance. That seems reason enough to try, so there we are. In examining this type of model it is found that more complex models can be used. There is now an interaction between defense powers and home/away and an effect of winter stop. This leads to a change in prediction values.
Ordinal model and Log linear regression
ordinal model
log linear model
Application
Ordinal model in R
To demonstrate the equivalence between polr and clm:
top <- data.frame(OffenseClub=c('FC Groningen','Vitesse')
(pol1 <- polr(oGoals ~OffenseClub,data=StartData))
Call:
polr(formula = oGoals ~ OffenseClub, data = StartData)
Coefficients:
OffenseClubAjax OffenseClubAZ
2.16090602 1.10515167
OffenseClubDe Graafschap OffenseClubExcelsior
-0.07000361 -0.47817103
OffenseClubFC Groningen OffenseClubFC Twente
0.05437062 1.61304748
OffenseClubFC Utrecht OffenseClubFeyenoord
0.72672725 1.40465078
OffenseClubHeracles Almelo OffenseClubNAC Breda
0.62502257 0.38942582
OffenseClubNEC OffenseClubPSV
0.26579358 1.77961585
OffenseClubRKC Waalwijk OffenseClubRoda JC
0.07824836 0.63463829
OffenseClubSC Heerenveen OffenseClubVitesse
1.64087778 0.42797219
OffenseClubVVV-Venlo
0.14843577
Intercepts:
0|1 1|2 2|3 3|4 4|5 5|6 6|7
-0.5749746 0.8583642 1.9763217 2.9660666 4.1504225 4.9698549 6.2901004
Residual Deviance: 1929.761
AIC: 1977.761
(clm1 <- clm(oGoals ~OffenseClub ,data=StartData))
formula: oGoals ~ OffenseClub
data: StartData
link threshold nobs logLik AIC niter max.grad
logit flexible 612 -964.88 1977.76 6(0) 6.04e-13
Coefficients:
OffenseClubAjax OffenseClubAZ
2.16095 1.10517
OffenseClubDe Graafschap OffenseClubExcelsior
-0.07005 -0.47813
OffenseClubFC Groningen OffenseClubFC Twente
0.05446 1.61290
OffenseClubFC Utrecht OffenseClubFeyenoord
0.72677 1.40463
OffenseClubHeracles Almelo OffenseClubNAC Breda
0.62502 0.38933
OffenseClubNEC OffenseClubPSV
0.26583 1.77970
OffenseClubRKC Waalwijk OffenseClubRoda JC
0.07833 0.63467
OffenseClubSC Heerenveen OffenseClubVitesse
1.64085 0.42778
OffenseClubVVV-Venlo
0.14849
Threshold coefficients:
0|1 1|2 2|3 3|4 4|5 5|6 6|7
-0.5750 0.8584 1.9763 2.9661 4.1504 4.9699 6.2902
predict(pol1,top,type=’p’)
0 1 2 3 4 5 6
1 0.3476590 0.3431691 0.1815278 0.07606575 0.03521247 0.009087138 0.005324424
2 0.2683624 0.3376048 0.2187080 0.10209439 0.04962636 0.013063007 0.007703923
7
1 0.001954373
2 0.002837110
predict(clm1,top,type=’p’)
$fit
0 1 2 3 4 5 6
1 0.3476380 0.3431713 0.1815361 0.07607152 0.03521588 0.009087829 0.005325017
2 0.2684004 0.3376141 0.2186884 0.10207952 0.04961821 0.013060380 0.007702605
7
1 0.001954409
2 0.002836354
Selecting a start model
fbpredict(clm3,”Roda JC”,”FC Utrecht”)
$details
Roda JC in rows against FC Utrecht in columns
0 1 2 3 4 5 6 7
0 0.0173 0.0424 0.0477 0.0297 0.0155 0.0040 0.0024 0.0009
1 0.0349 0.0856 0.0964 0.0599 0.0313 0.0082 0.0048 0.0018
2 0.0303 0.0741 0.0835 0.0519 0.0271 0.0071 0.0042 0.0015
3 0.0153 0.0375 0.0423 0.0263 0.0137 0.0036 0.0021 0.0008
4 0.0072 0.0176 0.0198 0.0123 0.0064 0.0017 0.0010 0.0004
5 0.0018 0.0044 0.0049 0.0031 0.0016 0.0004 0.0002 0.0001
6 0.0010 0.0026 0.0029 0.0018 0.0009 0.0002 0.0001 0.0001
7 0.0004 0.0009 0.0010 0.0006 0.0003 0.0001 0.0001 0
$`summary chances`
Roda JC equal FC Utrecht
0.4603544 0.2196707 0.3199749
Selecting model extensions; interactions
It is also possible to extend the model. This shows that there is an interaction between defense capabilities and playing home or away. The statistical significance is about p=0.06, which is low enough to consider this model for prediction purposes.
clm4a <- clm(oGoals ~OffenseClub*OffThuis + DefenseClub
,data=StartData)
clm4b <- clm(oGoals ~OffenseClub + DefenseClub*OffThuis
,data=StartData)
clm5 <- clm(oGoals ~(OffenseClub + DefenseClub)*OffThuis
,data=StartData)
anova (clm3,clm4a,clm5)
Likelihood ratio tests of cumulative link models:
formula: link: threshold:
clm3 oGoals ~ OffenseClub + DefenseClub + OffThuis logit flexible
clm4a oGoals ~ OffenseClub * OffThuis + DefenseClub logit flexible
clm5 oGoals ~ (OffenseClub + DefenseClub) * OffThuis logit flexible
no.par AIC logLik LR.stat df Pr(>Chisq)
clm3 42 1922.3 -919.14
clm4a 59 1938.2 -910.08 18.115 17 0.38164
clm5 76 1945.6 -896.81 26.552 17 0.06497 .
—
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ‘ 1
anova (clm3,clm4b,clm5)
Likelihood ratio tests of cumulative link models:
formula: link: threshold:
clm3 oGoals ~ OffenseClub + DefenseClub + OffThuis logit flexible
clm4b oGoals ~ OffenseClub + DefenseClub * OffThuis logit flexible
clm5 oGoals ~ (OffenseClub + DefenseClub) * OffThuis logit flexible
no.par AIC logLik LR.stat df Pr(>Chisq)
clm3 42 1922.3 -919.14
clm4b 59 1930.7 -906.36 25.560 17 0.08286 .
clm5 76 1945.6 -896.81 19.107 17 0.32242
—
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ‘ 1
The implication is that model ‘clm4b’ is now considered an alternative for model ‘clm3’. This makes for an interesting change in predictions. It can be seen that with this model FC Utrecht has a better chance to win than with ‘clm3’.
Winter break
Even more complex model
clmX <- clm(oGoals ~(OffenseClub + DefenseClub)*year + DefenseClub*OffThuis
,data=StartData)
anova(clm3,clmX)
Likelihood ratio tests of cumulative link models:
formula: link:
clm3 oGoals ~ OffenseClub + DefenseClub + OffThuis logit
clmX oGoals ~ (OffenseClub + DefenseClub) * year + DefenseClub * OffThuis logit
threshold:
clm3 flexible
clmX flexible
no.par AIC logLik LR.stat df Pr(>Chisq)
clm3 42 1922.3 -919.14
clmX 94 1951.3 -881.67 74.942 52 0.0203 *
—
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ‘ 1
anova(clm4b,clmX)
Likelihood ratio tests of cumulative link models:
formula:
clm4b oGoals ~ OffenseClub + DefenseClub * OffThuis
clmX oGoals ~ (OffenseClub + DefenseClub) * year + DefenseClub * OffThuis
link: threshold:
clm4b logit flexible
clmX logit flexible
no.par AIC logLik LR.stat df Pr(>Chisq)
clm4b 59 1930.7 -906.36
clmX 94 1951.3 -881.67 49.383 35 0.05424 .
—
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ‘ 1
anova(clm7,clmX)
Likelihood ratio tests of cumulative link models:
formula: link:
clm7 oGoals ~ (OffenseClub + DefenseClub) * year + OffThuis logit
clmX oGoals ~ (OffenseClub + DefenseClub) * year + DefenseClub * OffThuis logit
threshold:
clm7 flexible
clmX flexible
no.par AIC logLik LR.stat df Pr(>Chisq)
clm7 77 1945.7 -895.84
clmX 94 1951.3 -881.67 28.353 17 0.04098 *
—
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ‘ 1
Additional R code
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.