ordervec2supp3.Rd
Various functions for calculating the likelihood function for order
statistics in the context of hyper3 likelihood functions. Compare
ggol()
for hyper2
objects. Used in the
constructor()
suite of analysis.
num3(v,helped=NULL,lambda=1)
den3(v,helped=NULL,lambda=1)
char2nv(x)
ordervec2supp3(v,nonfinishers=NULL)
ordervec2supp3a(v,nonfinishers=NULL,helped=NULL,lambda=1)
rankvec_likelihood3(v,nonfinishers=NULL)
ordertable2supp3(a)
cheering3(v,e,help,nonfinishers=NULL)
args2ordervec(...)
Ranks in the form of a character vector. Element v[1]
is the first-placed competitor, element v[2]
the second, and
so on. For example, ordervec2supp3(c('b','b','a','c','a'))
Character vector (a set) showing players that did not finish. See details section and examples
An ordertable
vector of entities being helped
Parameters controlling non-independence with
e
a named integer vector specifying equivalence classes of
the competitors: names correspond to the competitors, values to
their equivalence class, and help
a numeric vector with
entries corresponding to the equivalence classes of e
and
values the strength of the support
A character vector of competitors
Arguments passed to args2ordervec()
Function args2ordervec()
takes arguments with names
corresponding to players, and entries corresponding to performances
(e.g. distances thrown by a javelin, or times for completing a
race). It returns a character vector indicating the rank statistic.
See examples, and also the javelin vignette.
Function ordervec2supp3()
takes character vector showing the
order of finishing [i.e. a rank statistic], and returns a generalized
Plackett-Luce support function in the form of a hyper3
object.
It can take the output of args2ordervec()
or rrace3()
.
For example:
ordervec2supp3(c("a","b"),nonfinishers=c("a","b"))
corresponds to a race between two twins of strength a
and two
twins of strength b
, with only one of each pair finishing;
a
comes first and b
comes second; symbolically
$$a\succ b\succ\left\lbrace a,b\right\rbrace\longrightarrow \mathcal{L}(a,b\left|a+b=1\right.)=\frac{a}{2a+2b}\cdot\frac{b}{a+2b}$$
Further,
ordervec2supp3(c("a","b"),c("a","b","c"))
corresponds to adding a singleton competitor of strength c
who
did not finish:
$$a\succ b\succ\left\lbrace a,b,c\right\rbrace\longrightarrow \mathcal{L}(a,b,c\left|a+b+c=1\right.)=\frac{a}{2a+2b+c}\cdot\frac{b}{a+2b+c}$$
(observe that this likelihood function is informative about
\(c\)). See the examples section below. Experimental function
ordervec2supp3a()
is a generalized version of
ordervec2supp3()
that allows for cheering effects.
Functions num3()
and den3()
are low-level helper
functions that calculate the numerator and denominator for
Plackett-Luce likelihood functions with clones; used in
ordervec2supp3()
and ordervec2supp3a()
.
Function ordertable2supp3()
takes an order table (the canonical
example is the constructors' formula 1 grand prix results, see
constructor.Rd
and returns a generalized Plackett-Luce support
function in the form of a hyper3
object.
Function char2nv()
takes a character vector and returns a named
vector with entries corresponding to their names' counts. It is used
in the extraction and replacement methods for hyper3
objects.
Function cheering3()
is a generalization of
ordervec2supp3()
. Competitors who are not mentioned in
argument e
are assumed to be in an equivalence class of size 1,
that is, they are not supported (or indeed suppressed) by anyone else:
they are singletons in the terminology of Hankin (2006). Extensive
discussions are presented at inst/plackett_luce_monster.Rmd
and
inst/eurovision.Rmd
.
File inst/javelin.Rmd
and inst/race3.Rmd
show some
use-cases for these functions.
Function ordervec2supp3()
is mis-named [it takes a rank
vector, not an order vector]; it will be renamed
rankvec_likelihood3()
, eventually.
ordervec2supp3(c("a","a","b","c","a","b","c"))
#> log( (a=1)^3 * (a=1, b=1, c=1)^-1 * (a=1, b=1, c=2)^-1 * (a=1, b=2,
#> c=2)^-1 * (a=2, b=2, c=2)^-1 * (a=3, b=2, c=2)^-1 * (b=1)^2 * (b=1,
#> c=1)^-1 * (c=1)^1)
ordervec2supp3(rrace3())
#> log( (a=1)^2 * (a=1, b=4, c=1)^-1 * (a=1, b=4, c=2)^-1 * (a=1, b=4,
#> c=2, d=1)^-1 * (a=2, b=4, c=2, d=1)^-1 * (b=1)^3 * (b=2)^-1 * (b=3)^-1
#> * (b=3, c=1)^-1 * (b=4, c=1)^-1 * (c=1)^2 * (d=1)^1)
ordervec2supp3(c("a","b"),nonfinishers=c("a","b")) # a > b >> {a,b}
#> log( (a=1)^1 * (a=1, b=2)^-1 * (a=2, b=2)^-1 * (b=1)^1)
(o <- args2ordervec(a=c(1,6,9), b=c(2,3,4), c=c(1.1,11.1)))
#> [1] "a" "c" "b" "b" "b" "a" "a" "c"
H <- ordervec2supp3(o)
H
#> log( (a=1)^3 * (a=1, c=1)^-1 * (a=2, b=1, c=1)^-1 * (a=2, b=2, c=1)^-1
#> * (a=2, b=3, c=1)^-1 * (a=2, b=3, c=2)^-1 * (a=2, c=1)^-1 * (a=3, b=3,
#> c=2)^-1 * (b=1)^3 * (c=1)^1)
# equalp.test(H) # takes too long for here
## Race: six competitors a-f finishing in alphabetical order. Mutually
## supporting groups: (acd), (bf), (e). Competitor "e" is not
## suppported by anyone else (he is a singleton) so does not need to be
## mentioned in argument 'e' and there are only two helpfulnesses to be
## considered: that of (acd) and that of (bf), which we will take to be
## 1.88 and 1.1111 respectively:
cheering3(v=letters[1:6],e=c(a=1,c=1,b=2,d=1,e=2),help=c(1.88,1.1111))
#> log( (a=1)^1 * (a=1, b=1, c=1, d=1, e=1, f=1)^-1 * (b=1)^1 * (b=1,
#> c=1.88, d=1.88, e=1, f=1)^-1 * (c=1.88)^1 * (c=1.88, d=1.88, e=1.1111,
#> f=1)^-1 * (d=1.88)^1 * (d=1.88, e=1.1111, f=1)^-1 * (e=1.1111)^1 *
#> (e=1.1111, f=1)^-1)
## Another race: four competitors, including two clones of "a", and two
## singletons "b" and "c". Here "a" helps his clone at 1.88; and "b"
## and "c" help one another at 1.111:
cheering3(v=c("a","b","a","c"),e=c(a=1,b=2,c=2),help=c(1.8,1.111))
#> log( (a=1)^1 * (a=1.8)^1 * (a=1.8, b=1, c=1)^-1 * (a=1.8, c=1.111)^-1 *
#> (a=2, b=1, c=1)^-1 * (b=1)^1)
## Same race as above but this time there are two clones of "b", one of
## whom did not finish:
cheering3(v=c("a","b","a","c"),e=c(a=1,b=2,c=2),help=c(1.8,1.111),"b")
#> log( (a=1)^1 * (a=1.8)^1 * (a=1.8, b=1.111, c=1.111)^-1 * (a=1.8, b=2,
#> c=1)^-1 * (a=2, b=2, c=1)^-1 * (b=1)^1 * (b=1.111, c=1.111)^-1 *
#> (c=1.111)^1)
## Most common case would be that the clones help each other but noone
## else:
cheering3(v=c("a","b","a","c"),e=c(a=1,b=2,c=3),help=c(1.8,1.111,1),"b")
#> log( (a=1)^1 * (a=1.8)^1 * (a=1.8, b=1.111, c=1)^-1 * (a=1.8, b=2,
#> c=1)^-1 * (a=2, b=2, c=1)^-1 * (b=1)^1 * (b=1.111, c=1)^-1 * (c=1)^1)