factorize {student} | R Documentation |
Factorizing matrices with various method.
factorize(x, method = c("chol", "chol.pivot", "eigen", "svd"), ...)
x |
|
method |
|
... |
additional arguments passed to the underlying main functions; see the source code for details. |
When the factor R is multiplied from the right to an
(n, d)-matrix of independent standard normals, one obtains
a sample from a multivariate normal with zero mean vector and
covariance matrix x
.
The factor, that is, the factorized matrix
. This is a
matrix R such that such that R^T R equals x
.
Marius Hofert
rstudent()
where factorize()
is used.
## Generate a random correlation matrix in dimension 5 d <- 5 set.seed(271) A <- matrix(runif(d * d), ncol = d) P <- cov2cor(A %*% t(A)) ## Factorizations A.chol <- factorize(P) # Cholesky factor A.chol.pivot <- factorize(P, method = "chol.pivot") # with pivoting A.eigen <- factorize(P, method = "eigen") # factor from eigendecomposition A.svd <- factorize(P, method = "svd") # from singular-value decomposition ## Check P.chol <- t(A.chol) %*% A.chol P.chol.pivot <- t(A.chol.pivot) %*% A.chol.pivot P.eigen <- t(A.eigen) %*% A.eigen P.svd <- t(A.svd) %*% A.svd stopifnot(all.equal(P.chol, P), all.equal(P.chol.pivot, P), all.equal(P.eigen, P), all.equal(P.svd, P))