| MonteCarloStat | R Documentation |
Using a multivariate normal model, random populations are generated using the supplied covariance matrix. A statistic is calculated on the random population and compared to the statistic calculated on the original matrix.
MonteCarloStat(
cov.matrix,
sample.size,
iterations,
ComparisonFunc,
StatFunc,
parallel = FALSE
)
cov.matrix |
Covariance matrix. |
sample.size |
Size of the random populations |
iterations |
Number of random populations |
ComparisonFunc |
Comparison functions for the calculated statistic |
StatFunc |
Function for calculating the statistic |
parallel |
if TRUE computations are done in parallel. Some foreach back-end must be registered, like doParallel or doMC. |
Since this function uses multivariate normal model to generate populations, only covariance matrices should be used.
The random populations are simulated in the main process, in the same order whether or not
parallel = TRUE; only the statistics are computed in parallel.
Populations whose comparison fails or is NA are redrawn up to 100 times, then an error is raised;
a single warning reports that redraws happened.
a data frame with one row per random population: a factor column X1 with the
population number and the comparison values (named as the result of ComparisonFunc, or V1, V2, ...).
Diogo Melo, Guilherme Garcia
BootstrapRep, AlphaRep
cov.matrix <- RandomMatrix(5, 1, 1, 10)
MonteCarloStat(cov.matrix, sample.size = 30, iterations = 50,
ComparisonFunc = function(x, y) PCAsimilarity(x, y)[1],
StatFunc = cov)
#Calculating R2 confidence intervals
r2.dist <- MonteCarloR2(RandomMatrix(10, 1, 1, 10), 30)
quantile(r2.dist)
## Not run:
#Multiple threads can be used with some foreach backend library, like doParallel
library(doParallel)
registerDoParallel(cores = 2)
MonteCarloStat(cov.matrix, sample.size = 30, iterations = 100,
ComparisonFunc = function(x, y) KrzCor(x, y)[1],
StatFunc = cov,
parallel = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.