Print.Rd
Print methods for hyper2
and hyper3
objects
# S3 method for class 'hyper2'
print(x, ...)
# S3 method for class 'hyper3'
print(x, ...)
Returns the hyper2
or hyper3
object it was sent,
invisibly.
Function pnv()
(“print named
vector”) takes a named vector and returns a character string
that is used in the hyper3
print method. It is sensitive to
base R print options such as digits
and scipen
.
Currently there is no space around the “=” symbol but this is
easy to change.
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; a warning indicates
nonzero sum of powers, which should prompt us to check the coding.
Vignette zeropower
gives a discussion of this issue.
Sometimes the use of pnv()
can be confusing, as distinct
brackets can appear to be identical, as per the example. See how the
two terms with power \(-1\) appear to be identical but actually
differ by 1e-12
, invisible to the print method which only shows
seven significant figures.
data(chess)
chess
#> log(Anand^36 * (Anand + Karpov)^-35 * (Anand + Topalov)^-35 * Karpov^22
#> * (Karpov + Topalov)^-18 * Topalov^30)
getOption("digits")
#> [1] 7
hyper3(list(c(a=1), c(a=1, b=pi),c(a=1, b=pi+1e-12)), powers = c(2, -1, -1))
#> log( (a=1)^2 * (a=1, b=3.141593)^-1 * (a=1, b=3.141593)^-1)