rCor {metaSEM} | R Documentation |
Generate (Nested) Sample/Population Correlation/Covariance Matrices
Description
It generates (nested) random sample or population correlation or
covariance matrices. rCor()
is a wrapper to call
rCorPop()
and then rCorSam()
.
Usage
rCor(Sigma, V, n, corr=TRUE, raw.data=FALSE,
nonPD.pop=c("replace", "nearPD", "accept"),
nonPD.sam=c("stop", "nearPD"))
rCorPop(Sigma, V, k, corr=TRUE,
nonPD.pop=c("replace", "nearPD", "accept"))
rCorSam(Sigma, n, corr=TRUE, raw.data=FALSE,
nonPD.sam=c("stop", "nearPD"))
rCor3L(Sigma, V.B, V.W, n, cluster, corr=TRUE, raw.data=FALSE,
nonPD.pop=c("replace", "nearPD", "accept"),
nonPD.sam=c("stop", "nearPD"))
Arguments
Sigma |
A list of population correlation/covariance matrices or a single matrix |
V |
A variance-covariance matrix of Sigma. |
V.B |
A variance-covariance matrix of between-study Sigma. |
V.W |
A variance-covariance matrix of within-study Sigma |
n |
A vector or a single sample sizes. |
cluster |
A vector of number of studies in clusters. |
corr |
Logical. Whether to generate correlation or covariance matrices. |
raw.data |
Logical. Whether correlation/covariance matrices are generated via raw.data or directly from a Wishart distribution. |
nonPD.pop |
If it is |
nonPD.sam |
If it is |
k |
A vector or a single number of studies. |
Value
An object of the generated population/sample correlation/covariance matrices.
Author(s)
Mike W.-L. Cheung <mikewlcheung@nus.edu.sg>
Examples
Sigma <- matrix(c(1, .2, .3,
.2, 1, .4,
.3, .4, 1), ncol=3, nrow=3)
V <- diag(c(.1, .1, .1))
## Generate two population correlation matrices
Pop.corr <- rCorPop(Sigma, V, k=2)
Pop.corr
summary(Pop.corr)
## Generate two sample correlation matrices
rCorSam(Sigma=Pop.corr, n=c(10, 10))
## The above code is the same as the following one
rCor(Sigma, V, n=c(10, 10))