pval: Compute p-Value For a Test Statistic

Description Usage Arguments Details Value References Examples

Description

Compute the p-value of a test statistic for Monte Carlo tests.

Usage

1
pval(S, sample_S, alternative = NULL, unif_gen = NULL)

Arguments

S

The value of the test statistic

sample_S

Simulated values of the

alternative

A string specifying the alternative hypothesis, or NULL

unif_gen

If not NULL, the function generating uniformly-distributed random variables for breaking ties; if NULL, no tie breaking is done

Details

Let S be a test statistic and S_i be simulated values of that test statistic under the null hypothesis, with 1 ≤q i ≤q N. If unif_gen is not NULL, this function computes p-values via

p = \hat{p} = \frac{1}{N}∑_{i = 1}^{N} I_{\{(S, U_0) ≤q (S_i, U_i)\}}

where I_{\{S \in A\}} = 1 if S \in A and is 0 otherwise, U_i are uniformly distributed random variables, and the ordering over tuples is lexicographical ordering, as described by \insertCitedufour06;textualMCHT.

If unif_gen is NULL, then the random variables are not generated and not used to break ties.

This function is designed to handle an alternative parameter similar to what appears in other stats functions like t.test. If alternative is "less", then p = \hat{p}; if alternative is "greater", then p = 1 - \hat{p}; and if alternative is "two.sided", then p = 2 \min(\hat{p}, 1 - \hat{p}). Any other value raises an error.

The parameter S is S, and the vector sample_S is the vector containing the values S_i.

Value

A number representing the p-value.

References

\insertAllCited

Examples

1
2
3
sample_S <- rnorm(10)
pval(1.01, sample_S)
pval(1.01, sample_S, alternative = "greater")

ntguardian/MCHT documentation built on May 26, 2019, 9:33 a.m.