Wikipedia gives a nice summary in table form of Formula 1 racing results on pages like https://en.wikipedia.org/wiki/2017_Formula_One_World_Championship (at World Drivers' Championship standings) but the data format is commonly used for many sports [see ordertable.Rd] and function ordertable2supp() translates such tables into a hyper2 support function and also a order table.

Both functions interpret zero to mean “Did not finish” (wikipedia usually signifies DNF as a blank).

ordertable2supp(x, noscore, incomplete=TRUE)
ordervec2supp(d)

Arguments

x

Data frame, see details

d

A named numeric vector giving order; zero entries are interpreted as that competitor coming last (due to, e.g., not finishing)

incomplete

Boolean, with FALSE meaning to insist that each rank \(1,2,...,n\) is present [zero entries mean “did not place” irregardless]. The default TRUE allows for gaps. This is useful if we are considering the first few lines of an ordertable because there might be missing ranks.

noscore

Character vector giving the abbreviations for a non-finishing status such as “did not finish” or “disqualified”. A missing argument is interpreted as c("Ret", "WD", "DNS", "DSQ", "DNP", "NC")

Details

Function ordertable2supp() is intended for use on order tables such as found at https://en.wikipedia.org/wiki/2019_Moto3_season. This is a common format, used for Formula 1, motoGP, and other racing sports. Prepared text versions are available in the package in the inst/ directory, for example inst/motoGP_2019.txt. Use read.table() to create a data frame which can be interpreted by ordertable2supp().

Function ordervec2supp() takes an order vector d and returns the corresponding Plackett-Luce loglikelihood function as a hyper2 object. It requires a named vector; names of the elements are interpreted as names of the players. Use argument pnames to supply the players' names (see the examples).


> x <- c(b=2,c=3,a=1,d=4,e=5) # a: 1st, b: 2nd, c: 3rd etc
> ordervec2supp(x)
log( a * (a + b + c + d + e)^-1 * (a + b + d + e)^-1 * b * (b + d +
e)^-1 * c * (d + e)^-1 * e)

$$ \frac{a}{a+b+c+d+e}\cdot \frac{b}{b+c+d+e}\cdot \frac{c}{c+d+e}\cdot \frac{d}{d+e}\cdot \frac{e}{e} $$

Zero entries mean “did not finish”:


> ordervec2supp(c(b=1,a=0,c=2))  # b: 1st, a: DNF, c: second
log((a + b + c)^-1 * (a + c)^-1 * b * c)
  

$$ \frac{b}{a+b+c}\cdot \frac{c}{a+c} $$

Note carefully the difference between ordervec2supp() and rankvec_likelihood(), which takes a character vector:


>  names(sort(x))
[1] "a" "b" "c" "d" "e"
> rankvec_likelihood(names(sort(x)))
log( a * (a + b + c + d + e)^-1 * b * (b + c + d + e)^-1 * c * (c + d +
e)^-1 * d * (d + e)^-1)
> rankvec_likelihood(names(sort(x))) == ordervec2supp(x)
[1] TRUE
>

Function order_obs() was used in the integer-indexed paradigm but is obsolete in the name paradigm. A short vignette applying ordervec2supp() and ordertable2supp() to the salad dataset of the prefmod package [and further analysed in the PlackettLuce package] is presented at inst/salad.Rmd.

Value

Returns a hyper2 object

Author

Robin K. S. Hankin

Examples

ordertable2supp(soling_table)
#> log(UK^6 * (UK + USA + australia + canada + denmark + finland + france
#> + germany + italy + netherlands + norway + nz + russia + spain +
#> sweden)^-1 * (UK + USA + australia + canada + denmark + finland +
#> france + germany + italy + netherlands + norway + nz + russia + spain +
#> sweden + ukraine)^-6 * (UK + USA + australia + canada + denmark +
#> finland + france + germany + italy + netherlands + nz + russia + spain
#> + sweden)^-1 * (UK + USA + australia + canada + denmark + finland +
#> france + germany + italy + netherlands + nz + russia + spain + sweden +
#> ukraine)^-1 * (UK + USA + australia + canada + denmark + finland +
#> france + germany + italy + netherlands + russia + spain + sweden)^-1 *
#> (UK + USA + australia + canada + denmark + finland + france + germany +
#> italy + norway + nz + russia + spain + sweden + ukraine)^-3 * (UK + USA
#> + australia + canada + denmark + finland + france + germany + italy +
#> norway + nz + spain + sweden + ukraine)^-1 * (UK + USA + australia +
#> canada + denmark + finland + france + germany + italy + norway + spain
#> + sweden + ukraine)^-1 * (UK + USA + australia + canada + denmark +
#> france + germany + italy + netherlands + russia + spain + sweden)^-1 *
#> (UK + USA + australia + canada + denmark + france + germany + italy +
#> russia + spain + sweden)^-1 * (UK + USA + australia + canada + denmark
#> + france + germany + russia + spain + sweden)^-1 * (UK + USA + canada +
#> denmark + finland + france + germany + italy + netherlands + norway +
#> nz + russia + spain + sweden + ukraine)^-1 * (UK + USA + canada +
#> denmark + finland + france + germany + italy + netherlands + norway +
#> russia + spain + sweden + ukraine)^-1 * (UK + USA + canada + denmark +
#> finland + france + germany + italy + netherlands + russia + spain +
#> sweden + ukraine)^-1 * (UK + australia + canada + denmark + finland +
#> france + germany + italy + netherlands + nz + russia + spain + sweden +
#> ukraine)^-1 * (UK + australia + canada + denmark + finland + france +
#> germany + italy + norway + nz + russia + spain + sweden + ukraine)^-2 *
#> (UK + australia + canada + denmark + finland + france + germany + italy
#> + norway + russia + spain + sweden + ukraine)^-1 * (UK + australia +
#> canada + denmark + finland + france + germany + italy + norway + spain
#> + sweden + ukraine)^-1 * (UK + australia + canada + denmark + finland +
#> france + germany + italy + spain + sweden + ukraine)^-1 * (UK +
#> australia + canada + denmark + finland + france + italy + netherlands +
#> nz + russia + spain + sweden + ukraine)^-1 * (UK + australia + canada +
#> denmark + finland + france + italy + netherlands + nz + spain + sweden
#> + ukraine)^-1 * (UK + australia + canada + denmark + finland + france +
#> italy + netherlands + nz + spain + ukraine)^-1 * (UK + australia +
#> canada + denmark + finland + germany + italy + norway + nz + russia +
#> spain + sweden + ukraine)^-1 * (UK + australia + canada + finland +
#> france + germany + italy + norway + russia + spain + sweden +
#> ukraine)^-1 * (UK + australia + canada + finland + france + germany +
#> italy + norway + russia + spain + ukraine)^-1 * (UK + australia +
#> canada + finland + france + germany + italy + norway + russia +
#> ukraine)^-1 * (UK + australia + canada + finland + france + germany +
#> italy + spain + sweden + ukraine)^-1 * (UK + australia + canada +
#> finland + france + germany + italy + spain + ukraine)^-1 * (UK +
#> australia + canada + finland + germany + italy + norway + russia +
#> ukraine)^-1 * (UK + australia + finland + germany + italy + norway +
#> russia + ukraine)^-1 * (UK + australia + finland + germany + italy +
#> norway + ukraine)^-1 * (UK + australia + finland + germany + norway +
#> ukraine)^-1 * (UK + australia + finland + norway)^-1 * (UK + australia
#> + finland + norway + ukraine)^-1 * (UK + canada + denmark + finland +
#> france + italy + netherlands + nz + spain)^-1 * (UK + canada + denmark
#> + finland + france + italy + netherlands + nz + spain + ukraine)^-1 *
#> (UK + canada + finland + france + germany + italy + spain + ukraine)^-1
#> * (UK + canada + finland + germany + italy + spain + ukraine)^-1 * (UK
#> + finland + germany + italy + spain + ukraine)^-1 * (UK + germany +
#> italy + spain)^-1 * (UK + germany + italy + spain + ukraine)^-1 * USA^5
#> * (USA + australia + canada + denmark + france + germany + russia +
#> spain + sweden)^-1 * (USA + australia + canada + denmark + france +
#> germany + spain + sweden)^-1 * (USA + australia + denmark + france +
#> germany + spain + sweden)^-1 * (USA + australia + denmark + france +
#> spain + sweden)^-1 * (USA + canada + denmark + finland + france +
#> germany + italy + netherlands + russia + spain + sweden + ukraine)^-1 *
#> (USA + canada + denmark + finland + france + germany + netherlands +
#> russia + spain + sweden)^-1 * (USA + canada + denmark + finland +
#> france + germany + netherlands + russia + spain + sweden + ukraine)^-1
#> * (USA + canada + denmark + finland + france + netherlands + russia +
#> spain + sweden)^-1 * (USA + canada + denmark + finland + france +
#> netherlands + spain + sweden)^-1 * (USA + canada + denmark + finland +
#> netherlands + spain)^-1 * (USA + canada + denmark + finland +
#> netherlands + spain + sweden)^-1 * (USA + canada + denmark + finland +
#> spain)^-1 * (USA + canada + finland + spain)^-1 * (USA + denmark +
#> france + spain + sweden)^-1 * (USA + denmark + france + sweden)^-1 *
#> (USA + denmark + sweden)^-1 * (USA + finland + spain)^-1 * (USA +
#> spain)^-1 * australia^6 * (australia + canada + denmark + finland +
#> germany + italy + norway + nz + russia + spain + sweden + ukraine)^-1 *
#> (australia + canada + denmark + finland + germany + italy + nz + russia
#> + spain + sweden + ukraine)^-1 * (australia + canada + denmark +
#> finland + germany + italy + nz + spain + sweden + ukraine)^-1 *
#> (australia + canada + denmark + finland + germany + italy + spain +
#> sweden + ukraine)^-1 * (australia + canada + denmark + finland +
#> germany + italy + sweden + ukraine)^-1 * (australia + finland +
#> norway)^-1 * canada^6 * (canada + denmark + finland + france + italy +
#> netherlands + nz + spain)^-1 * (canada + denmark + finland + germany +
#> italy + sweden + ukraine)^-1 * (canada + denmark + finland + italy +
#> sweden + ukraine)^-1 * (canada + finland + italy + sweden + ukraine)^-1
#> * denmark^5 * (denmark + finland + france + italy + netherlands + nz +
#> spain)^-1 * (denmark + finland + france + italy + netherlands +
#> spain)^-1 * (denmark + finland + italy + netherlands + spain)^-1 *
#> (denmark + sweden)^-1 * finland^6 * (finland + italy + netherlands +
#> spain)^-1 * (finland + italy + spain)^-1 * (finland + italy + sweden +
#> ukraine)^-1 * (finland + norway)^-1 * (finland + spain)^-1 * france^6 *
#> germany^6 * (germany + italy + spain)^-1 * italy^5 * (italy + spain)^-1
#> * (italy + sweden + ukraine)^-1 * netherlands^6 * norway^5 * nz^6 *
#> russia^6 * spain^5 * sweden^5 * (sweden + ukraine)^-1 * ukraine^6)

# competitors a-f, racing at two venues:
x <- data.frame(
    venue1=c(1:5,"Ret"),venue2=c("Ret",4,"Ret",1,3,2),
    row.names=letters[1:6])

## First consider all competitors; incomplete=FALSE checks that all
## finishing competitors have ranks 1-n in some order for some n:

ordertable2supp(x,incomplete=FALSE)
#> log( a * (a + b + c)^-1 * (a + b + c + d + e + f)^-2 * (a + b + c +
#> e)^-1 * (a + b + c + e + f)^-1 * b^2 * (b + c + d + e + f)^-1 * c * (c
#> + d + e + f)^-1 * d^2 * (d + e + f)^-1 * e^2 * (e + f)^-1 * f)


## Now consider just a-d; must use default incomplete=TRUE as at venue2
## the second and third ranked competitors are not present in x[1:4,]:

ordertable2supp(x[1:4,])   
#> log( a * (a + b + c)^-1 * (a + b + c + d)^-2 * b^2 * (b + c + d)^-1 * c
#> * (c + d)^-1 * d)





## Function ordervec2supp() is lower-level, used for order vectors:

a1 <- c(a=2,b=3,c=1,d=5,e=4) # a: 2nd, b: 3rd, c: 1st, d: 5th, e: 4th
a2 <- c(a=1,b=0,c=0,d=2,e=3) # a: 2nd, b: DNF, c: DNF, d: 2nd, e: 3rd
a3 <- c(a=1,b=3,c=2)         # a: 1st, b: 3rd, c: 2nd. NB only a,b,c competed
a4 <- c(a=1,b=3,c=2,d=0,e=0) # a: 1st, b: 3rd, c: 2nd, d,e: DNF


## results of ordervec2supp() may be added with "+" [if the observations
## are independent]:

H1 <- ordervec2supp(a1) + ordervec2supp(a2) + ordervec2supp(a3)
H2 <- ordervec2supp(a1) + ordervec2supp(a2) + ordervec2supp(a4)

## Thus H1 and H2 are identical except for the third race.  In H1, 'd'
## and 'e' did not compete, but in H2, 'd' and 'e' did not finish (and
## notionally came last):

pmax(H1)
#> log(a^3 * (a + b + c)^-1 * (a + b + c + d + e)^-2 * (a + b + d + e)^-1
#> * b * (b + c)^-1 * (b + c + d + e)^-1 * (b + c + e)^-1 * (b + d + e)^-1
#> * c^2 * d * (d + e)^-1 * e^2)
pmax(H2)   # d,e not finishing affects their estimated strength
#> log(a^3 * (a + b + c + d + e)^-3 * (a + b + d + e)^-1 * b^2 * (b + c +
#> d + e)^-2 * (b + c + e)^-1 * (b + d + e)^-2 * c^2 * d * (d + e)^-1 *
#> e^2)