Print: Print methods

PrintR Documentation

Print methods

Description

Print methods for hyper2 and hyper3 objects

Usage

## S3 method for class 'hyper2'
print(x, ...)
## S3 method for class 'hyper3'
print(x, ...)

Arguments

x

An object of class hyper2 or hyper3

...

Further arguments, currently ignored

Details

Used mainly for their side-effect of printing the log-likelihood function. In the print method, a natural logarithm is indicated with “log()”—not “ln()”—consistent with R builtin terminology base::log().

The hyper2 print method is sensitive to option give_warning_on_nonzero_power_sum. If TRUE, a warning is issued if the powers have nonzero sum. This is usually what you want because observations are typically multinomial. If FALSE, the warning is suppressed. One often needs hyper2 objects with nonzero sum as the following snippet attests:

  H1 <- hyper2(list('a'),1)
  H2 <- hyper2(list('a',c('a','b')),c(1,-1))

Above, both objects are legitimate likelihood functions; both correspond to the observation “player a won once”. But they differ in that H1 corresponds to “player a came first in a field of unspecified players” while H2 corresponds to “player a came first in a field comprising a and b”. Sometimes you want H1 but (in my experience) mostly it is a result of coding error. Also note the following snippet:

  icons["L"] %<>% inc
  icons[c("L","NB")]  %<>% dec

The above two lines correspond to “Take the icons likelihood function and add to it the (independent) observation that a correspondent found ‘London’ to be more concerning than ‘the Norfolk Broads’”. But after the first line and before the second, icons has a nonzero power sum, pending addition of another term. At this point, icons is arguably an incomplete likelihood function as the players have not been specified; its nonzero power sum is an indicator that it is a temporary object. That's OK as long as we remember to add the denominator (as carried out in the next line) which would mean multiplying by (L+NB)^{-1}, restoring the zero power sum. If we forget to do this, the print method gives us a warning which should prompt us to check the coding.

Value

Returns the hyper2 or hyper3 object it was sent, invisibly. Function pnv() converts a named vector to a character string that is used in the hyper3 print method.

Author(s)

Robin K. S. Hankin

Examples

data(chess)
chess

hyper2 documentation built on Aug. 21, 2022, 1:05 a.m.