3 abr. 2014

SVD (Now aplying Singular Value Decomposition)


I have the ocasion to ask to Mark Westerhaus what kind of PC algorithms use Win ISI. As always, he replies very quickly:

"WinISI uses SVD everywhere except the PCA regression option in GLOBAL, where it uses NIPALS"

By the way, as you know, Mark Westerhaus has received the EAS Award 2014.
See the post:

I have been writing the lasts post about NIPALS, but now I can continue with some posts doing the same with Singular Value Decomposition, and it would be interesting to make some comparisons with Win ISI.
For the NIPALS, I used a training set of sunflower see acquired in a NIR instrument, the scan goes from 1100 nm to 2500 nm , every 0,5 nm. So we have 1400 . 2 = 2800 data points or wavelength variables,  these means a lot of columns in the X matrix. The number of samples is 107.

So here I write some code to use SVD with my data:


sflw.msc3.tra_svd<-svd(sflw.msc3.tra$NIRmsc)
names(sflw.msc3.tra_svd)
             

#The output are: "d" "u" "v"
 U<-sflw.msc3.tra_svd$u              
 dim(U)      #Matrix U  (dim= 107.107)

 d<-sflw.msc3.tra_svd$d             

 D<-diag(d)                         
 dim(D)      #Matrix D  (dim= 107.107)

 V<-sflw.msc3.tra_svd$v             

 dim(V)      #Matrix V  (dim= 2800.107)

Now we can calculate the original matrix as

 X<-U %*% D %*% t(V)

  # we can multilpy this: U %*% D  [107.107].[107.107]
  # The result is a [107.107] matrix
  # Finally we have to multiply a [107.107] matrix by a [107.2800]
  # beeing the result a [107.2800] matrix (The X matrix)


No hay comentarios:

Publicar un comentario