View source: R/randtest.dispRity.R
randtest.dispRity | R Documentation |
Performs a random test (aka permutation test) on a matrix
or a dispRity
object.
## S3 method for class 'dispRity' randtest( data, subsets, metric, replicates = 100, resample = TRUE, alter = "two-sided", ... )
data |
The |
subsets |
A |
metric |
A |
replicates |
A |
resample |
|
alter |
The alternative hypothesis. Can be |
... |
optional arguments to be passed to |
This test checks whether the metric calculated on a given subset of the data is significantly different from the metric calculated on any random subset of the same size. In other words: does the given subset have a clearly different disparity value than the rest of the data?
First, the metric
(statistic) is applied to the subset
sampled from the data
(population).
Second, the metric
is applied to random equally sized subsets from the data
.
If the observed difference falls out of the random differences distribution, the differences are significant.
This algorithm is based on a similar procedure than in link[ade4]{rantest}
.
If data
is a dispRity
object, the subsets
, metric
and replicates
can be left missing and are automatically inherited from the dispRity
if it contains respectively subsets (from chrono.subsets
or custom.subsets
) a metric
(from dispRity
) and bootstrap draws (from boot.matrix
).
This function returns a "randtest"
object that can be passed to the generic S3 functions print.randtest
or plot.randtest
.
The output also contains to extra elements output$observed
and output$random
containing the raw results of respectively the observed and random tests.
Thomas Guillerme
randtest
## Simple example dummy_matrix <- matrix(rnorm(500), 100, 5) ## Testing whether the mean of a random subset ## is different than the means of 100 subsets dummy_test <- randtest.dispRity(dummy_matrix, subset = sample(1:100, 20), metric = mean) dummy_test ; plot(dummy_test) ## Applying this on dispRity objects data(disparity) test_disparity <- test.dispRity(disparity, test = randtest.dispRity) ## The summarised results summary(test_disparity) ## Plotting the results plot(test_disparity)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.