posdef.approx {monomvn} | R Documentation |
Check if the matrix is positive definite via attempted
Cholesky decomposition, and if not use the
sechol
function to get the nearest
approximate Cholesky decomposition from which to recover an
approximate covariance matrix which is positive definite.
posdef.approx(S, name = "S", quiet=FALSE)
S |
square matrix which is supposed to be positive
definite |
name |
name of the matrix – used for printing errors and warnings |
quiet |
whether or not to print a warning when a
non-positive definite matrix is found |
If successful, returns a matrix
which is positive definite:
either the original matrix, or a nearby positive definite approximation.
Requires the accuracy package. If S
is far from positive
definite, then the method may fail.
Robert B. Gramacy bobby@statslab.cam.ac.uk
Micah Altman, Jeff Gill and Michael McDonald (2003).
Numerical Issues in Statistical Computing for the Social
Scientist. John Wiley and Sons, New York.
http://www.hmdc.harvard.edu/micah_altman/numal/
http://www.statslab.cam.ac.uk/~bobby/monomvn.html
## most likely generates a matrix which is close to positive definite ## but not quite s <- matrix(rnorm(100), ncol=5) S <- (t(s) %*% s) + matrix(rnorm(25, sd=10), ncol=5) S ## a correction, quiet=TRUE so there is no warning printed posdef.approx(S, quiet=TRUE)