To cite the hyper2 package in publications, please use Hankin (2017).
Curling is a sport with
stones and brooms. Following dataset taken from
wikipedia,
women’s tournament:
curling_table <- read.table("curling.txt", header = TRUE)
curling_table
## X1998 X2002 X2006 X2010 X2014 X2018
## Canada 1 3 3 2 1 6
## China NA NA NA 3 7 5
## Denmark 2 9 9 5 6 9
## Germany 8 5 NA 6 NA NA
## GB 4 1 5 7 3 4
## Italy NA NA 10 NA NA NA
## Japan 6 8 7 8 5 3
## Norway 5 7 4 NA NA NA
## Russia NA 10 6 9 9 NA
## South_Korea NA NA NA NA 8 2
## Sweden 3 6 1 1 2 1
## Switzerland NA 2 2 4 4 7
## US 7 4 8 10 10 8
Thus the first row shows that Canada came first in 1998, third in
2002, and so on; the first column shows that in 1998, Canada came
first, China did not compete [NA meaning did not compete], Denmark
came second, and so on. First we will interpret NA in the same way
as DNS in the context of formula 1 motor racing. We need to define
a new data frame, b:
ct <- curling_table
ct[is.na(ct)] <- "DNS"
ct
## X1998 X2002 X2006 X2010 X2014 X2018
## Canada 1 3 3 2 1 6
## China DNS DNS DNS 3 7 5
## Denmark 2 9 9 5 6 9
## Germany 8 5 DNS 6 DNS DNS
## GB 4 1 5 7 3 4
## Italy DNS DNS 10 DNS DNS DNS
## Japan 6 8 7 8 5 3
## Norway 5 7 4 DNS DNS DNS
## Russia DNS 10 6 9 9 DNS
## South_Korea DNS DNS DNS DNS 8 2
## Sweden 3 6 1 1 2 1
## Switzerland DNS 2 2 4 4 7
## US 7 4 8 10 10 8
In this form we can easily convert to a support function:
curling1 <- suppfun(ordertable(ct))
summary(curling1)
## A hyper2 object of size 13.
## pnames: Canada China Denmark GB Germany Italy Japan Norway Russia South_Korea Sweden Switzerland US
## Number of brackets: 61
## Sum of powers: 0
##
## Table of bracket lengths:
## 1 4 5 6 7 8 9 10 11 12 13
## 13 4 5 6 6 6 6 6 5 3 1
##
## Table of powers:
## -6 -3 -2 -1 1 2 3 4 5 6
## 1 1 2 44 1 1 3 1 1 6
curling1_maxp <- maxp(curling1)
pie(curling1_maxp)
NAThere is a different interpretation of NA entries. We might hold
that no inference should be made from a team’s entry being NA entry
because that that team did not compete. This means that function
ordertable2supp() is not appropriate and we need to use a different
method:
curling2 <- hyper2()
for(i in seq_len(ncol(curling_table))){
x <- curling_table[,i]
names(x) <- rownames(curling_table)
curling2 <- curling2 + suppfun(x[!is.na(x)])
}
summary(curling2)
## A hyper2 object of size 13.
## pnames: Canada China Denmark GB Germany Italy Japan Norway Russia South_Korea Sweden Switzerland US
## Number of brackets: 62
## Sum of powers: 0
##
## Table of bracket lengths:
## 1 2 3 4 5 6 7 8 9 10
## 12 5 6 6 6 6 6 6 5 4
##
## Table of powers:
## -2 -1 2 3 4 5 6
## 1 49 2 3 1 2 4
(curling2_maxp <- maxp(curling2))
## Canada China Denmark GB Germany Italy
## 2.4150e-01 7.3200e-02 1.5799e-02 9.3284e-02 2.1434e-02 1.0019e-06
## Japan Norway Russia South_Korea Sweden Switzerland
## 3.3554e-02 6.4935e-02 1.0315e-02 4.3806e-02 2.6510e-01 1.2705e-01
## US
## 1.0023e-02
pie(curling2_maxp)
par(pty="s")
plot(log10(curling1_maxp),log10(curling2_maxp),asp=1,pch=16,xlim=c(-2.6,0),ylim=c(-2.6,0))
posn <- c(Canada=2, China=4, Denmark=4, Germany=4, GB=4, Italy=1, Japan=2, Norway=2,
Russia=4, South_Korea=4, Sweden=4, Switzerland=2, US=4)
for(i in seq_len(nrow(curling_table))){
text(log10(curling1_maxp)[i],log10(curling2_maxp)[i],rownames(curling_table)[i],col="gray",pos=posn[i])
}
abline(0,1)
grid()
The two likelihood systems have very different evaluates.
Following lines create curling.rda, residing in the data/ directory of the package.
save(curling_table,curling1,curling2,curling1_maxp,curling2_maxp,file="curling.rda")
Curling at the Winter Olympics, https://en.wikipedia.org/w/index.php?title=Curling_at_the_Winter_Olympics&oldid=998891075 (last visited Jan. 21, 2021).
hyper2 Package: Likelihood Functions for Generalized Bradley-Terry Models.” The R Journal 9 (2): 429–39.