ge yreyt
2003-Jul-11 15:49 UTC
[R] using SVD to get an inverse matrix of covariance matrix
Dear R-users, I have one question about using SVD to get an inverse matrix of covariance matrix Sometimes I met many singular values d are close to 0: look this example $d [1] 4.178853e+00 2.722005e+00 2.139863e+00 1.867628e+00 1.588967e+00 [6] 1.401554e+00 1.256964e+00 1.185750e+00 1.060692e+00 9.932592e-01 [11] 9.412768e-01 8.530497e-01 8.211395e-01 8.077817e-01 7.706618e-01 [16] 7.007119e-01 6.237449e-01 5.709922e-01 5.550645e-01 5.062633e-01 [21] 4.792278e-01 4.222183e-01 3.660419e-01 3.293667e-01 3.026312e-01 [26] 2.942821e-01 2.811098e-01 2.626359e-01 2.199134e-01 1.943776e-01 [31] 1.712359e-01 1.561616e-01 1.359116e-01 1.280704e-01 1.099847e-01 [36] 1.013633e-01 9.622151e-02 8.396722e-02 7.083654e-02 6.755967e-02 [41] 5.392306e-02 3.807169e-02 2.942905e-02 2.726249e-02 4.555067e-16 [46] 3.095299e-16 2.918951e-16 2.672369e-16 2.336190e-16 2.239488e-16 [51] 2.089471e-16 1.970283e-16 1.863823e-16 1.775903e-16 1.698164e-16 [56] 1.594850e-16 1.500927e-16 1.469157e-16 1.406057e-16 1.366468e-16 [61] 1.319553e-16 1.252144e-16 1.193341e-16 1.142526e-16 1.064905e-16 [66] 1.040117e-16 1.005124e-16 9.310727e-17 8.995158e-17 8.529797e-17 [71] 8.204344e-17 7.759612e-17 7.478445e-17 7.225679e-17 6.709050e-17 [76] 5.996665e-17 5.830386e-17 5.687619e-17 5.121094e-17 4.848857e-17 [81] 4.549679e-17 4.307547e-17 3.830520e-17 3.450571e-17 3.312035e-17 [86] 3.260300e-17 2.399392e-17 2.141970e-17 1.996962e-17 1.881993e-17 [91] 1.567323e-17 1.062695e-17 6.730278e-18 2.118570e-18 4.991002e-19 Since the inverse matrix = u * inverse(d) * v', If I calculate inverse d based on formula : 1/d, then most values of inverse matrix will be huge. This must be not a good way. MOre special case, if a single value is 0, then we can not calculate inverse d based on 1/d. Therefore, my question is how I can calculate inverse d (that is inverse diag(d) more efficiently??? Thanks ping ______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca
Thomas Lumley
2003-Jul-11 16:16 UTC
[R] using SVD to get an inverse matrix of covariance matrix
On Fri, 11 Jul 2003, ge yreyt wrote:> Dear R-users, > > I have one question about using SVD to get an inverse > matrix of covariance matrix > > Sometimes I met many singular values d are close to 0: > look this example<snip>> most values of inverse matrix > will be huge. This must be not a good way. MOre > special case, if a single value is 0, then > we can not calculate inverse d based on 1/d. > > Therefore, my question is how I can calculate inverse > d (that is inverse diag(d) more efficiently??? >If singular values are zero the matrix doesn't have an inverse: that is, the equation Mx=b will have multiple solutions for any given b. It is possible to get a pseudoinverse, a matrix M that picks out one of the solutions. One way to do this is to set the diagonal to 1/d where d is not (nearly) zero and to 0 when d is (nearly) zero. One place to find a discussion of this is `Matrix Computations' by Golub and van Loan. -thomas
Jerome Asselin
2003-Jul-11 16:24 UTC
[R] using SVD to get an inverse matrix of covariance matrix
If some of the eigenvalues of a square matrix are (close to) zero, then it's inverse does not exist. However, you can always calculate it's generalized inverse ginv(). library(MASS) help(ginv) It'll allow you to specify a "tol" argument: tol: A relative tolerance to detect zero singular values. Hope that helps, Jerome On July 11, 2003 08:49 am, ge yreyt wrote:> Content-Length: 2154 > Status: R > X-Status: N > > Dear R-users, > > I have one question about using SVD to get an inverse > matrix of covariance matrix > > Sometimes I met many singular values d are close to 0: > look this example ><snip>> > Since the inverse matrix = u * inverse(d) * v', > If I calculate inverse d based on formula : 1/d, then > most values of inverse matrix > will be huge. This must be not a good way. MOre > special case, if a single value is 0, then > we can not calculate inverse d based on 1/d. > > Therefore, my question is how I can calculate inverse > d (that is inverse diag(d) more efficiently??? > > > Thanks > > ping > > > ______________________________________________________________________ > Post your free ad now! http://personals.yahoo.ca > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help