ggrl.Rd
Various functions for calculating the likelihood function for order statistics
ggrl(H, ...)
general_grouped_rank_likelihood(H, ...)
goodbad(winners,losers)
elimination(all_players)
rank_likelihood(M,times=1)
rankvec_likelihood(v,nonfinishers)
race(v,nonfinishers)
Object of class hyper2
Numeric or character vectors specifying groups of players with equal rank, with higher-ranking groups coming earlier in the argument list
Numeric or character vectors specifying competitors. See details
In function rank_likelihood()
, a matrix with each
row corresponding to a race (or judge). The columns
correspond to the finishing order; thus a=M[i,j]
means that
competitor a
finished in place j
in race i
Vector specifying the number of times each row is observed
A character vector specifying ranks. Thus
c("b","c","a")
means that b
came first, c
second,
and a
third
A character vector with entries corresponding to
competitors who did not finish. Thus
race(c("a","b"),c("p","q"))
means that the field is
a,b,c,d
; a
came first, b
came second and c
and d
did not finish
These functions are designed to return likelihood functions, in the
form of lists of hyper2()
objects, for typical order statistics
such as the results of rowing heats or MasterChef tournaments.
Function ggrl()
is an easily-typed alias for
general_grouped_rank_likelihood()
.
Function goodbad()
is a convenience function for ggrl()
in which a bunch of contestants is judged. It returns a likelihood
function for the observation that the members of one subset were
better than those of another. Thus
goodbad(letters[1:3],letters[4:5])
corresponds to the
observation that d
and e
were put into an elimination
trial (and abc
were not).
Function elimination()
gives a likelihood function for situations
where the weakest player is identified at each stage and
subsequently eliminated from the competition. It is intended for
situations like the Great British Bake-off and Masterchef in which the
observation is which player was chosen to leave the show. In this
function, argument all_players
is sensitive to order, unlike
choose_winners()
and choose_losers()
(an integer
n
is interpreted as letters[seq_len(n)]
). Element
i
of all_players
is the \(i^\mathrm{th}\) player
to be eliminated. Thus the first element of all_players
is the
first player to be eliminated (and would be expected to have the
lowest strength). The final element of all_players
is the last
player to be eliminated (or alternatively the only player not to be
eliminated).
Function rank_likelihood()
takes a matrix M
with rows
corresponding to a judge (or race); column names are interpreted as
competitor names. A named vector is coerced to a one-row matrix.
Each row of M
is an order statistic: thus c(3,4,2,1)
means that person 3 came first, person 4 came second, person 2 came
third and person 1 came last. Note that in data frames like
F1_table_2017
, each column is a race.
Function rankvec_likelihood()
takes a character vector of
competitors with the order of elements corresponding to the finishing
order; a Plackett-Luce likelihood function is returned. Thus
v=c("d","b","c","a")
corresponds to d
coming first,
b
second, c
third, and a
fourth. Function
race()
is an arguably more memorable synonym.
An example of race()
is given in inst/rowing.Rmd
, and
examples of ggrl()
are given in inst/loser.Rmd
and
inst/masterchef.Rmd
.
W <- hyper2(pnames=letters[1:5])
W1 <- ggrl(W, 'a', letters[2:4],'e') # 6-element list
W2 <- ggrl(W, 'b', letters[3:5],'a') # 6-element list
like_single_list(equalp(W1),W1)
#> [1] 0.05
like_series(equalp(W1),list(W1,W2))
#> [1] -5.991465
if(FALSE){ # takes too long
# run 10 races:
r1 <- rrank(10,p=(7:1)/28)
colnames(r1) <- letters[1:7]
# Likelihood function for r1:
rank_likelihood(r1)
rank_likelihood(r1,nonfinishers=letters[8:9])
# convert a rank table to a support function:
rank_likelihood(wikitable_to_ranktable(volvo_table))
H <- hyper2()
for(i in 1:20){
H <- H + race(sample(letters[1:5],sample(3,1),replace=FALSE))
}
equalp.test(H) # should not be significant (null is true)
H1 <- hyper2(pnames=letters[1:5])
H2 <- choose_losers(H1,letters[1:4],letters[1:2]) # {a,b} vs {c,d}; {a,b} lost
maxplist(H2,control=list(maxit=1)) # control set to save time
}