Learn R Programming

hyper2 (version 3.0-0)

hyper2: Basic functions in the hyper2 package

Description

Basic functions in the hyper2 package

Usage

hyper2(L=list(), d=0, pnames)
# S3 method for hyper2
brackets(H)
# S3 method for hyper2
powers(H)
# S3 method for hyper2
pnames(H)
# S3 method for 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\).

Author

Robin K. S. Hankin

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\).

See Also

Ops.hyper2, Extract.hyper2, loglik, hyper2-package psubs

Examples

Run this code
o <- hyper2(list("a","b","c",c("a","b"),letters[1:3]),1:5) 

# Verify that the MLE is invariant under reordering
pnames(icons) <- rev(pnames(icons))
maxp(icons) - icons_maxp # should be small

Run the code above in your browser using DataLab