[R] La.svd of a symmetric matrix

Stefano Sofia stefano.sofia at regione.marche.it
Mon Jan 18 09:49:04 CET 2010


Thanks to David Winsemius for his help about the use of La.svd. Two more questions.

QUESTION 1
Your example works fine, but the one that I propose below does not.
Your example:

> Asymm
     [,1] [,2] [,3]
[1,]   66  101   95
[2,]  101   76  104
[3,]   95  104   26

> La.svd(Asymm)
$d
[1] 257.72248  59.79550  29.92698

$u
           [,1]       [,2]        [,3]
[1,] -0.5853410 -0.2966601 -0.75456525
[2,] -0.6225788 -0.4317295  0.65269081
[3,] -0.5193954  0.8518230  0.06801466

$vt
           [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,]  0.2966601  0.4317295 -0.85182300
[3,]  0.7545652 -0.6526908 -0.06801466

> La.svd(Asymm)$vt*c(1,-1,-1)
           [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,] -0.2966601 -0.4317295  0.85182300
[3,] -0.7545652  0.6526908  0.06801466
> t(La.svd(Asymm)$u)
           [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,] -0.2966601 -0.4317295  0.85182300
[3,] -0.7545652  0.6526908  0.06801466

My example:

> Asymmdefpos
     [,1] [,2] [,3]
[1,]    2   -1    0
[2,]   -1    2   -1
[3,]    0   -1    2

> La.svd(Asymmdefpos)
$d
[1] 3.4142136 2.0000000 0.5857864

$u
           [,1]          [,2]      [,3]
[1,] -0.5000000 -7.071068e-01 0.5000000
[2,]  0.7071068 -1.288303e-16 0.7071068
[3,] -0.5000000  7.071068e-01 0.5000000

$vt
           [,1]         [,2]       [,3]
[1,] -0.5000000 7.071068e-01 -0.5000000
[2,] -0.7071068 1.511107e-17  0.7071068
[3,]  0.5000000 7.071068e-01  0.5000000

> La.svd(Asymmdefpos)$vt*c(1,-1,-1)
           [,1]          [,2]       [,3]
[1,] -0.5000000  7.071068e-01 -0.5000000
[2,]  0.7071068 -1.511107e-17 -0.7071068
[3,] -0.5000000 -7.071068e-01 -0.5000000
> t(La.svd(Asymmdefpos)$u)
           [,1]          [,2]       [,3]
[1,] -0.5000000  7.071068e-01 -0.5000000
[2,] -0.7071068 -1.288303e-16  0.7071068
[3,]  0.5000000  7.071068e-01  0.5000000

Are these two matrices equal up to an orthonormal transformation? If yes, how can I find out the right transformation?

QUESTION 2

One option of La.svd is nu=0.
I read carefully the manual, but I am not able to understand when this option is impostant.
Is it important to set mu=0 (only) when I deal with singular matrices?

Thank you for your attention and your help
Stefano Sofia



> Dear R list users,
> the singluar value decomposition of a symmetric matrix M is UDV^(T),
> where U = V.
> La.svd(M) gives as output three elements: the diagonal of D and the
> two orthogonal matrices u and vt (which is already the transpose of
> v).
>
> I noticed that the transpose of vt is not exactly u. Why is that?

Well, it would have been u and t(vt) that you might have been thinking
should be equal. And they are equal up to an orthonormal transformation.

 > samp <-sample(1:100, 9)
 > M <- matrix(samp,3)+matrix(samp,3,byrow=T)
 >  all.equal( La.svd(M)$vt *c(1,-1,1) , t(La.svd(M)$u) )
[1] "Mean relative difference: 0.6169069"
 > M
      [,1] [,2] [,3]
[1,]   66  101   95
[2,]  101   76  104
[3,]   95  104   26
 > La.svd(M)$vt
            [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,]  0.2966601  0.4317295 -0.85182300
[3,]  0.7545652 -0.6526908 -0.06801466
 >  t(La.svd(M)$u)
            [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,] -0.2966601 -0.4317295  0.85182300
[3,] -0.7545652  0.6526908  0.06801466
 >  all.equal( La.svd(M)$vt *c(1,-1,-1) , t(La.svd(M)$u) )
[1] TRUE

And, of course, numerical accuracy gets in the way of exact equality:
 >   La.svd(M)$vt *c(1,-1,-1) == t(La.svd(M)$u)
       [,1]  [,2]  [,3]
[1,] FALSE FALSE FALSE
[2,] FALSE FALSE FALSE
[3,]  TRUE FALSE  TRUE

--
David.

AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni confidenziali, pertanto ? destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si ? il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. 6 della  DGR n. 1394/2008 si segnala che, in caso di necessit? ed urgenza, la risposta al presente messaggio di posta elettronica pu? essere visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.



More information about the R-help mailing list