rarefy.stat | R Documentation |
Rarefies or bootstraps a statistic
rarefy.stat(data, stat.fun, rarefaction, replicates = 100, observed, ...)
data |
The dataset upon which to calculate the statistics (a |
stat.fun |
The function to calculate the statistic (in format |
rarefaction |
The amount of data to resample. Leave as |
replicates |
The number of replicates (default is |
observed |
Optional, an set observed statistic value. |
... |
Optional arguments to be passed to stat.fun. |
The bootstrap/rarefaction procedure is used with replacement (sample(..., replace = TRUE)
) so that when simply bootstrapping the data (no-rarefaction), each row of the dataset has a equal chance of being sampled multiple times.
If the observed
value is not provide, the observed statistic is directly measured as stat.fun(data)
.
A vector of differences between the rarefy statistics and the observed statistics.
Thomas Guillerme
rand.test
## A dataset with two variables
data <- replicate(2, rnorm(50))
## A function to get a statistic (the Student statistic)
my.stat <- function(data) {t.test(data[1, ], data[2, ])$statistic[[1]]}
## Rarefy the statistic for only 10 rows
results <- rarefy.stat(data, my.stat, rarefaction = 10)
head(results)
## Summarising the results
quantile(results)
boxplot(results); abline(h = 0, lty = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.