rand.test | R Documentation |
Performs a random test
rand.test(
distribution,
subset,
test,
replicates = 100,
resample = TRUE,
rarefaction,
test.parameter = FALSE,
parameter,
alternative = "two-sided",
...
)
distribution |
A |
subset |
A |
test |
The test to apply (a |
replicates |
A |
resample |
|
rarefaction |
Optional, a |
test.parameter |
Optional, whether to test the calculated parameter ( |
parameter |
Optional, if the parameter is tested, which parameter to select (can be left empty if |
alternative |
Optional, if the parameter is tested, what is the alternative hypothesis. Can be |
... |
Any optional arguments to be passed to |
First, the subset of the distribution is compared to the whole distribution (observed difference). Second, random equally sized subsets are compared to the whole distribution (random differences). If the observed difference falls out of the random differences distribution, the differences are significant.
If test.parameter
is set to TRUE
, the code tests whether the resulting test parameters between the observed subset and the random ones are significantly different (base on the same procedure as in link[ade4]{rantest}
).
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
link[ade4]{randtest}
## Loading the geomorph dataset
require(geomorph)
data(plethodon)
## Performing the Procrustes superimposition
proc_super <- gpagen(plethodon$land, print.progress = FALSE)
## Getting the two most different specimen based on their landmark change radii
var_range <- variation.range(proc_super)
set.seed(1)
## Selecting 6 random landmarks
random_part <- sample(1:nrow(var_range), 6)
## Testing the difference between the two sets of landmarks
stats::t.test(var_range[random_part, "radius"], var_range[-random_part, "radius"])
## Testing whether this difference is expected by chance
random_test <- rand.test(var_range[, "radius"], random_part, test = stats::t.test,
test.parameter = TRUE)
## Summarising the results
random_test
## Plotting the results
plot(random_test)
## Rarefying the area difference to 4 elements without testing the parameter
rarefy_test <- rand.test(var_range[, "radius"], random_part, rarefaction = 5,
test = stats::t.test)
plot(rarefy_test)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.