| tests | R Documentation |
Tests different nulls against a free alternative
equalp.test(H, startp=NULL, ...)
knownp.test(H, p, ...)
samep.test(H, i, give=FALSE, startp=NULL, ...)
specificp.test(H, i, specificp=1/size(H),
alternative = c("two.sided","less","greater"), ...)
specificp.ne.test(H, i, specificp=1/size(H), ...)
specificp.gt.test(H, i, specificp=1/size(H), delta=1e-5, ...)
specificp.lt.test(H, i, specificp=1/size(H), ...)
## S3 method for class 'hyper2test'
print(x, ...)
H |
A likelihood function, an object of class |
p |
In |
... |
Further arguments passed by |
startp |
Starting value for optimization |
i |
A character vector of names |
specificp |
Strength, real number between 0 and 1 |
alternative |
a character string specifying the alternative
hypothesis, must be one of |
give |
Boolean, with |
x |
Object of class |
delta |
Small value for numerical stability |
Given a hyper2 likelihood function, there are a number of
natural questions to ask about the strengths of the players; see
Hankin 2010 (JSS) for examples. An extended discussion is presented
in vignette “hyper2” and the functions documented here
cover most of the tests used in the vignette.
The tests return an object with class hyper2test, which has its
own print method.
Function equalp.test(H,p) tests the null that all
strengths are equal to vector p. If p is missing, it
tests H_0\colon p_1=p_2=\cdots=p_n=\frac{1}{n}, for example equalp.test(icons)
Function knownp.test() tests the null that the strengths
are equal to the elements of named vector p; it is a
generalization of equalp.test(). Example:
knownp.test(icons,zipf(6)).
Function specificp.test(H,i,p) tests
H_0\colon p_i=p, for example
specificp.test(icons,"NB",0.1)
Function samep.test() tests H_0\colon
p_{i_1}=p_{i_2}=\cdots=p_{i_k}, for example
samep.test(icons,c("NB","L")) tests that NB has the same
strength as L.
Functions specificp.ne.test(H,i,p),
specificp.gt.test(H,i,p), and specificp.lt.test(H,i,p)
are low-level helper functions that implement one- or two-sided versions
of specificp.test() via the alternative argument,
following t.test()
The test functions return a list with class "hyper2test"
containing the following components:
statistic |
the difference in support between the null and alternative |
p.value |
the (asymptotic) p-value for the test, based on Wilks's theorem |
estimate |
the maximum likelihood estimate for |
method |
a character string indicating what type of test was performed |
data.name |
a character string giving the name(s) of the data. |
Function specificp.gt.test() includes quite a bit of messing
about to ensure that frequently-used idiom like
specificp.gt.test(icons,"NB",0) works as expected, testing a null
of p_NB=0 (observe that specificp.ne.test(icons,"NB",0)
and specificp.gt.test(icons,"NB",0) will (correctly) throw an
error). In the case of testing a strength's being zero, the support
function is often quite badly-behaved near the constraint [think tossing
a coin with probability p twice, observing one head and one tail,
and testing p=0; at the constraint, the likelihood is zero, the
support negative infinity, and the gradient of the support is infinite].
Numerically, the code tests p_NB=delta. Note that similar
machinations are not required in specificp.lt.test() because a
null of p_NB=1 is unrealistic.
Function samep.test() does not have access to gradient
information so it is slow, inaccurate, and may fail completely for
high-dimensional datasets. If any(i==n), this constrains the
fillup value; this makes no difference mathematically but the function
idiom is involved.
In functions specificp.??.test(H,i,...), if i is not
present in H, an error is returned although technically the
result should be “not enough evidence to reject”, as H is
uninformative about i.
maxp
equalp.test(chess)
# samep.test(icons,c("NB","L"))
# knownp.test(icons,zipf(icons))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.