genPositiveDefMat {clusterGeneration} | R Documentation |
Generate a positive definite matrix/covariance matrix.
genPositiveDefMat(dim, covMethod=c("eigen", "unifcorrmat"), rangeVar=c(1,10), lambdaLow=1, ratioLambda=10)
dim |
Dimension of the matrix to be generated. |
covMethod |
Method to generate positive definite matrices/covariance matrices. Choices are “eigen” or “unifcorrmat”; see details below. |
rangeVar |
Range for variances of a covariance matrix (see details). The default range is [1, 10] which can generate reasonable variability of variances. |
lambdaLow |
Lower bound on the eigenvalues of cluster covariance matrices.
If the argument covMethod="eigen" , eigenvalues are generated for cluster covariance matrices.
The eigenvalues are randomly generated from the
interval [lambdaLow , lambdaLow *ratioLambda ].
In our experience, lambdaLow =1 and ratioLambda =10
can give reasonable variability of the diameters of clusters.
lambdaLow should be positive.
|
ratioLambda |
The ratio of the upper bound of the eigenvalues to the lower bound of the
eigenvalues of cluster covariance matrices. See lambdaLow .
|
The current version of the function genPositiveDefMat
implements two
methods to generate random covariance matrices. The first method, denoted by
“eigen”, first randomly generates eigenvalues
(λ_1,...,λ_p) for the covariance matrix
(boldsymbol{Σ}), then
uses columns of a randomly generated orthogonal matrix
(boldsymbol{Q}=(boldsymbol{α}_1,...,boldsymbol{α}_p))
as eigenvectors. The covariance matrix boldsymbol{Σ} is then
contructed as
boldsymbol{Q}*diag(λ_1,...,λ_p)*boldsymbol{Q}^T.
The second method, denoted as “unifcorrmat”, first generates a random
correlation matrix (boldsymbol{R}) via the method proposed in Joe (2006),
then randomly generates variances (σ_1^2,...,σ_p^2) from
an interval specified by the argument rangeVar
. The covariance matrix
boldsymbol{Σ} is then constructed as
diag(σ_1,...,σ_p)*boldsymbol{R}*diag(σ_1,...,σ_p).
egvalues |
eigenvalues of Sigma |
Sigma |
positive definite matrix/covariance matrix |
Weiliang Qiu stwxq@channing.harvard.edu
Harry Joe harry@stat.ubc.ca
Joe, H. (2006) Generating Random Correlation Matrices Based on Partial Correlations. Journal of Multivariate Analysis, 97, 2177–2189.
genPositiveDefMat("unifcorrmat",dim=4) genPositiveDefMat("eigen",dim=5)