Basic functions in the hyper2 package

hyper2(L=list(), d=0, pnames)
# S3 method for class 'hyper2'
brackets(H)
# S3 method for class 'hyper2'
powers(H)
# S3 method for class 'hyper2'
pnames(H)
# S3 method for class 'suplist'
pnames(H)
size(H)
as.hyper2(L,d,pnames)
is.hyper2(H)
is_valid_hyper2(L,d,pnames)
is_constant(H)

Arguments

H

A hyper2 object

L

A list of character vectors whose elements specify the brackets of a hyper2 object

d

A vector of powers; hyper2() recycles only if d is of length 1

pnames

A character vector specifying the names of \(p_1\) through \(p_n\).

Details

These are the basic functions of the hyper2 package. Function hyper() is the low-level creator function; as.hyper2() is a bit more user-friendly and attempts to coerce its arguments into a suitable form; for example, a matrix is interpreted as rows of brackets.

Functions pnames() and pnames<-() are the accessor and setter methods for the player names. Length-zero character strings are acceptable player names. The setter method pnames<-() can be confusing. Idiom such as pnames(H) <- value does not change the likelihood function of H (except possibly its domain). When called, it changes the pnames internal vector, and will throw an error if any element of c(brackets(H)) is not present in value. It has two uses: firstly, to add players who do not appear in the brackets; and secondly to rearrange the pnames vector (the canonical use-case is pnames(H) <- rev(pnames(H))). If you want to change the player names, use psubs() to substitute players for other players.

Function is_valid_hyper2() tests for valid input, returning a Boolean. This function returns an error if a bracket contains a repeated element, as in hyper2(list(c("a","a")),1).

Note that it is perfectly acceptable to have an element of pnames that is not present in the likelihood function (this would correspond to having no information about that particular player).

Function size() returns the (nominal) length \(n\) of nonnegative vector \(p=\left(p_1,\ldots,p_n\right)\) where \(p_1+\cdots+p_n=1\).

Author

Robin K. S. Hankin

Examples

(o <- hyper2(list("a","b","c",c("a","b"),letters[1:3]),c(1:3,-1,-5)))
#> log( a * (a + b)^-1 * (a + b + c)^-5 * b^2 * c^3)
(p <- hyper2(list("a",c("a","d")),c(1,-1)))
#> log( a * (a + d)^-1)
o+p
#> log(a^2 * (a + b)^-1 * (a + b + c)^-5 * (a + d)^-1 * b^2 * c^3)


# Verify that the MLE is invariant under reordering
pnames(icons) <- rev(pnames(icons))
maxp(icons) - icons_maxp # should be small
#>        WAIS          OA         THC          PB           L          NB 
#> -0.18363193 -0.06294993 -0.05447923  0.05447116  0.06295686  0.18363307