
To cite the hyper2 package in publications, please use
Hankin (2017).
library("hyper2", quietly=TRUE)
lines <- readLines("scottish_premier_league.txt")
orderstat <- lapply(lines, function(z) {as.character(read.table(text=z, header=FALSE)[-1])})
years <- sapply(lines, function(z) {as.numeric(read.table(text=z, header=FALSE)[1])})
names(years) <- NULL
names(orderstat) <- years
orderstat[[1]]
## [1] "Celtic" "Motherwell"
## [3] "Aberdeen" "Dundee United"
## [5] "Inverness Caledonian Thistle" "St Johnstone"
## [7] "Ross County" "St Mirren"
## [9] "Kilmarnock" "Partick Thistle"
## [11] "Hibernian" "Heart of Midlothian"
L <- hyper2()
for(i in seq_along(orderstat)){L <- L + race(orderstat[[i]])}
summary(L)
## A hyper2 object of size 17.
## pnames: Aberdeen Celtic Dundee Dundee United Falkirk Hamilton Academical Heart of Midlothian Hibernian Inverness Caledonian Thistle Kilmarnock Livingston Motherwell Partick Thistle Rangers Ross County St Johnstone St Mirren
## Number of brackets: 159
## Sum of powers: 0
##
## Table of bracket lengths:
## 1 2 3 4 5 6 7 8 9 10 11 12
## 17 13 13 13 13 13 13 12 13 13 13 13
##
## Table of powers:
## -2 -1 1 3 5 6 7 9 10 11 12 13
## 1 141 1 1 2 2 1 2 3 1 1 3
Find the evaluate:
M <- maxp(L)
M
## Aberdeen Celtic
## 0.0061065297 0.8995613922
## Dundee Dundee United
## 0.0009210060 0.0011457151
## Falkirk Hamilton Academical
## 0.0059280601 0.0006436086
## Heart of Midlothian Hibernian
## 0.0023807792 0.0035737483
## Inverness Caledonian Thistle Kilmarnock
## 0.0010619749 0.0012767732
## Livingston Motherwell
## 0.0010516915 0.0021367719
## Partick Thistle Rangers
## 0.0010640368 0.0692320839
## Ross County St Johnstone
## 0.0009278723 0.0017319899
## St Mirren
## 0.0012559665
pie(M)
Now profile likelihood for Celtic:
p <- seq(from=0.6, to=0.995, len=17)
s <- profsupp(L, "Celtic", p)
plot(p, s, type="b")
hyper2 Package: Likelihood Functions for Generalized Bradley-Terry Models.” The R Journal 9 (2): 429–39.