8 may 2013

Median absolute deviation

Median absolute deviation - Wikipedia, the free encyclopedia

   
This is a robust statistic to use indeed the standard deviation. You can see in this Wikipedia link details of the theory.
This post is just to see how we can use this statistic with R for the calculation of the Principal Components.
Using the R Library: pcaPP, we use the function:
PCAgrid (x, k = 2, method = c ("mad", "sd", "qn"),.............)
In this function, we select the method to use, beeing "mad", the default one. "X" is our spectral matrix, and "k" is the number of components to compute.
Doing this calculations, we get a matrix with the loadings, and another matrix with the scores, apart from other staistics and values.
To follow some rules let´s call P to our loading matrix, and T to our scores matrix.
library(pcaPP)
sflw.msc.rpc<-PCAgrid(sflw.msc$NIRmsc,k=4,scale=mad)
P<-sflw.msc.rpc$loadings
T<-sflw.msc.rpc$scores
pairs(T[,1:4],col=c("red","blue","green","brown")[sflw.msc$Set])
I can see the samples used in the calibration set in green color and other comming from diferent instruments in other colors, in order to study the patterns and to know better my database.


 
 Continue this post with: Detecting outliers (Mahalanobis)
 
 

No hay comentarios:

Publicar un comentario