set.seed(0)
knitr::opts_chunk$set(echo = TRUE)
library("hyper2")
library("magrittr")
options("digits" = 5)
knitr::include_graphics(system.file("help/figures/hyper2.png", package = "hyper2"))

To cite the hyper2 package in publications, please use @hankin2017_rmd. 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

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

In this form we can easily convert to a support function:

curling1 <- ordertable2supp(ct)
head(curling1)
curling1_maxp <- maxp(curling1)
pie(curling1_maxp)

Interpretation of NA

There 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 + ordervec2supp(x[!is.na(x)])
}
head(curling2)
(curling2_maxp <- maxp(curling2))
pie(curling2_maxp)

Comparison

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.

Package dataset {-}

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")

References {-}

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).



RobinHankin/hyper2 documentation built on April 21, 2024, 11:38 a.m.