Component p-value of a coin test, on the log scale in both tails
coin_component_logp.RdReturns \(\log(p)\) and \(\log(1 - p)\) for a fitted
coin independence test, taken from the test statistic and its
reference distribution rather than from coin::pvalue().
Arguments
- it
A fitted object from
coin::independence_test().- refit
A function of no arguments that refits the same test against a permutation reference, used only when the asymptotic reference saturates. Pass NULL to skip the fallback and accept an infinite log.
Details
pvalue() returns a number on the linear scale, and two things
go wrong there. A large statistic gives an upper-tail probability computed as
one minus a lower tail that has rounded to 1, so a p-value of 1e-194 is
reported as 0 even though a double could hold it. A statistic sitting exactly
on its null expectation gives a p-value of exactly 1, which is correct under
a continuous reference but leaves \(\log(1-p)\) at -Inf.
The first is repaired by asking pchisq() for the upper tail directly.
The second cannot be repaired within an asymptotic reference, because the
chi-square distribution has no atom at zero while the underlying rank or
distance statistic does. When it happens, this function refits the test
against the permutation distribution and returns the mid-p value, which is
strictly inside \((0,1)\) by construction, and warns.