mroot(A,rank=NULL,method="chol")
A
is known then it should
be supplied."chol"
to use pivoted choloeski decompositon,
which is fast but tends to over-estimate rank. "svd"
to use
singular value decomposition, which is slow, but is the most accurate way
to estimate rank.set.seed(0)
a <- matrix(runif(24),6,4)
A <- a%*%t(a) ## A is +ve semi-definite, rank 4
B <- mroot(A) ## default pivoted choleski method
tol <- 100*.Machine$double.eps
chol.err <- max(abs(A-B%*%t(B)));chol.err
if (chol.err>tol) warning("mroot (chol) suspect")
B <- mroot(A,method="svd") ## svd method
svd.err <- max(abs(A-B%*%t(B)));svd.err
if (svd.err>tol) warning("mroot (svd) suspect")
Run the code above in your browser using DataLab