[R] Cholesky Decomposition in R

Ravi Varadhan RVaradhan at jhmi.edu
Tue Mar 10 22:44:11 CET 2009


You can use singular value decomposition:

?svd

> svd(A)
$d
[1] 16.3405917  2.8996176  0.7597907  # This is your diagonal matrix "D"

$u
           [,1]       [,2]        [,3]
[1,] 0.08585595 -0.2420411  0.96645997
[2,] 0.40826313 -0.8763116 -0.25573252
[3,] 0.90881790  0.4165261  0.02357989

$v
           [,1]       [,2]        [,3]
[1,] 0.08585595 -0.2420411  0.96645997
[2,] 0.40826313 -0.8763116 -0.25573252
[3,] 0.90881790  0.4165261  0.02357989

>

Ravi. 


----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 

----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Manli Yan
Sent: Tuesday, March 10, 2009 5:33 PM
To: r-help at r-project.org
Subject: [R] Cholesky Decomposition in R

  Hi everyone:
  I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I
only found how to decomposite A in to  LL' by using chol(A),the function
Cholesky(A) doesnt work,any one know other command to decomposte A in to
LDL'

  My r code is:
library(Matrix)
A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3)

> chol(A)
     [,1] [,2] [,3]
[1,]    1    1    1
[2,]    0    2    2
[3,]    0    0    3

> Cholesky(A)
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function "Cholesky", for signature
"matrix"

whatz wrong???
thanks~

	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list