ordertable.Rd
Order tables
The package makes extensive use of order tables and these are discussed
here together with a list of order tables available in the package as
data. See also ranktable.Rd
.
Consider pentathlon_table
:
> pentathlon_table
shooting fencing swimming riding running
Moiseev 5 1 1 6 5
Zadneprovskis 6 2 5 5 1
Capalini 4 6 2 3 4
Cerkovskis 3 3 7 7 2
Meliakh 1 7 4 1 6
Michalik 2 4 6 2 7
Walther 7 5 3 4 3
Although pentathlon_table
is a dataset in the package, the source
dataset is also included in the inst/
directory as file
pentathlon.txt
; use idiom like
read.table("inst/pentathlon.txt")
to load the order table.
Object pentathlon_table
is a representative example of an
ordertable. Each row is a competitor, each column an event (venue,
judge, ...). The first row shows Moiseev's ranking in shooting
(5th), fencing (1st), and so on. The first column shows the ranks of
the competitors in shooting. Thus Moiseev came fifth, Zadneprovskis
came 6th, and so on.
However, to create a likelihood function we need ranks, not orders. We
need to know, for a given event, who came first, who came second, and so
on (an extended discussion on the difference between rank and order is
given at rrank). We can convert from an order table to a rank
table using ordertable_to_ranktable()
(see also
ranktable.Rd
):
> ordertable_to_ranktable(pentathlon_table)
c1 c2 c3 c4 c5
shooting Meliakh Michalik Cerkovskis Capalini Moiseev
fencing Moiseev Zadneprovskis Cerkovskis Michalik Walther
swimming Moiseev Capalini Walther Meliakh Zadneprovskis
riding Meliakh Michalik Capalini Walther Zadneprovskis
running Zadneprovskis Cerkovskis Walther Capalini Moiseev
c6 c7
shooting Zadneprovskis Walther
fencing Capalini Meliakh
swimming Michalik Cerkovskis
riding Moiseev Cerkovskis
running Meliakh Michalik
Above, we see the same data in a different format (an extended discussion on the difference between rank and order is given in rrank).
Many of the order tables in the package include entries that correspond to some variation on “did not finish”. Consider the volvo dataset:
> volvo_table_2014
leg1 leg2 leg3 leg4 leg5 leg6 leg7 leg8 leg9
AbuDhabi 1 3 2 2 1 2 5 3 5
Brunel 3 1 5 5 4 3 1 5 2
Dongfeng 2 2 1 3 DNF 1 4 7 4
MAPFRE 7 4 4 1 2 4 2 4 3
Alvimedica 5 5 3 4 3 5 3 6 1
SCA 6 6 6 6 5 6 6 1 7
Vestas 4 DNF DNS DNS DNS DNS DNS 2 6
In the above order table, we have DNF
for “did not finish”
and DNS
for “did not start”. The formula1
order
table has other similar entries such as DSQ
for
“disqualified” and a discussion is given at
ordertable2supp.Rd
.
Links are given below to all the order tables in the package. Note that
the table in inst/eurovision.Rmd
(wiki_matrix
) is not an
order table because no country is allowed to vote for itself.
To coerce a table like the Volvo dataset shown above into an order table
[that is, replace DNS
with zeros, and also force nonzero entries
to be contiguous], use as.ordertable()
.
ordertable_to_ranktable(soling_table)
#> c1 c2 c3 c4 c5 c6 c7 c8
#> I netherlands russia nz USA norway denmark sweden australia
#> II ukraine norway nz finland netherlands italy UK russia
#> III norway USA germany russia sweden australia ukraine UK
#> IV australia nz norway UK italy ukraine germany russia
#> V netherlands USA france UK norway russia nz spain
#> VI netherlands USA nz denmark sweden spain france canada
#> c9 c10 c11 c12 c13 c14 c15 c16
#> I france canada finland ukraine UK germany spain italy
#> II canada germany australia spain france USA sweden denmark
#> III canada nz france denmark netherlands italy finland spain
#> IV france sweden netherlands denmark canada finland spain USA
#> V australia germany denmark canada finland italy ukraine sweden
#> VI russia italy germany ukraine UK australia finland norway
ordertable2supp(soling_table) == soling # should be TRUE
#> [1] TRUE