View source: R/two-sample-test.R
two_sample_test | R Documentation |
This function carries out an hypothesis test in which the null hypothesis is that the two samples are governed by the same underlying generative probability distribution against the alternative hypothesis that they are governed by two different generative probability distributions.
two_sample_test(
x,
y,
stats = list(stat_t),
B = 1000L,
M = NULL,
alternative = "two_tail",
combine_with = "tippett",
type = "exact",
seed = NULL,
...
)
x |
A numeric vector or a numeric matrix or a list representing the 1st
sample. Alternatively, it can be a distance matrix stored as an object of
class |
y |
A numeric vector if |
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. |
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.
A user-specified function should have at least two arguments:
the first argument is data
which should be a list of the n1 + n2
concatenated observations with the original n1
observations from the first
sample on top and the original n2
observations from the second sample
below;
the second argument is perm_data
which should be an integer vector giving
the indices in data
that are considered to belong to the first sample.
It is possible to use the use_stat
function with nsamples = 2
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_t
function for an example.
n <- 10L
mx <- 0
sigma <- 1
# Two different models for the two populations
x <- rnorm(n = n, mean = mx, sd = sigma)
delta <- 10
my <- mx + delta
y <- rnorm(n = n, mean = my, sd = sigma)
t1 <- two_sample_test(x, y)
t1$pvalue
# Same model for the two populations
x <- rnorm(n = n, mean = mx, sd = sigma)
delta <- 0
my <- mx + delta
y <- rnorm(n = n, mean = my, sd = sigma)
t2 <- two_sample_test(x, y)
t2$pvalue
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.