R chol Function


chol() function compute the Choleski factorization of a real symmetric positive-definite square matrix.

chol(x, ...)


x: an object for which a method exists. The default method applies to real symmetric, positive-definite matrices
...

> x <- matrix(c(8,1,1,4),2,2)
> x

[,1] [,2]
[1,] 8 1
[2,] 1 4


> y <- chol(x)
> y

[,1] [,2]
[1,] 2.828427 0.3535534
[2,] 0.000000 1.9685020


> x <- matrix(rep(1:4),2,2)
> x

[,1] [,2]
[1,] 1 3
[2,] 2 4


> y <- chol(x)

Error in chol.default(x) :
the leading minor of order 2 is not positive definite



endmemo.com © 2024  | Terms of Use | Privacy | Home