[R] chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails

Charles C. Berry cberry at tajo.ucsd.edu
Sat Nov 21 18:11:51 CET 2009


On Sat, 21 Nov 2009, simona.racioppi at libero.it wrote:

> Hi Everyone,
>
> I need to take the square root of the following matrix:
>
>                [,1]               [,2]                [,3]
> [1,]  0.5401984 -0.3998675 -1.3785897
> [2,] -0.3998675  1.0561872  0.8158639
> [3,] -1.3785897  0.8158639  1.6073119
>
> I tried Choleski which fails. I then tried Choleski with pivoting, but
> unfortunately the square root I get is not valid. I also tried eigen
> decomposition but i did no get far.
>
> Any clue on how to do it?!


If you want to take the square root of a negative definite matrix, you 
could use

 	sqrtm( neg.def.mat )

from the expm package on rforge:

 	http://r-forge.r-project.org/projects/expm/

HTH,

Chuck


>
> Thanks,
> Simon
>
> ______________________________________________
> 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.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901




More information about the R-help mailing list