one_sample_test {flipr} | R Documentation |
One-Sample Permutation Test
Description
This function carries out an hypothesis test where the null hypothesis is that the sample is governed by a generative probability distribution which is centered and symmetric against the alternative hypothesis that they are governed by a probability distribution that is either not centered or not symmetric.
Usage
one_sample_test(
x,
stats = list(stat_max),
B = 1000L,
M = NULL,
alternative = "two_tail",
combine_with = "tippett",
type = "exact",
seed = NULL,
...
)
Arguments
x |
A numeric vector or a numeric matrix or a list representing the sample from which the user wants to make inference. |
stats |
A list of functions produced by |
B |
The number of sampled permutations. Default is |
M |
The total number of possible permutations. Defaults to |
alternative |
A single string or a character vector specifying whether
the p-value is right-tailed, left-tailed or two-tailed. Choices are
|
combine_with |
A string specifying the combining function to be used to
compute the single test statistic value from the set of p-value estimates
obtained during the non-parametric combination testing procedure. For now,
choices are either |
type |
A string specifying which formula should be used to compute the
p-value. Choices are |
seed |
An integer specifying the seed of the random generator useful for
result reproducibility or method comparisons. Default is |
... |
Extra parameters specific to some statistics. |
Value
A list
with three components: the value of the
statistic for the original two samples, the p-value of the resulting
permutation test and a numeric vector storing the values of the permuted
statistics.
User-supplied statistic function
A user-specified function should have at least two arguments:
the first argument is
data
which should be a list of then
observations from the sample;the second argument is
flips
which should be an integer vector giving the signs by which each observation indata
should be multiplied.
It is possible to use the use_stat
function with nsamples = 1
to have flipr automatically generate a template file for writing down
your own test statistics in a way that makes it compatible with the flipr
framework.
See the stat_max
function for an example.
Examples
n <- 10L
mu <- 3
sigma <- 1
# Sample under the null distribution
x1 <- rnorm(n = n, mean = 0, sd = sigma)
t1 <- one_sample_test(x1, B = 100L)
t1$pvalue
# Sample under some alternative distribution
x2 <- rnorm(n = n, mean = mu, sd = sigma)
t2 <- one_sample_test(x2, B = 100L)
t2$pvalue