23 feb 2014

NIPALS: Looking to the scores 3D plots

These are some 3D plots we can get from R to understand better the NIPALS function, and spectra reconstruction we have been talking in the lasts posts.
We can see the 3D cube score plots, draw the orthogonal projections to the different planes (in this case to the plane formed by PC1 and PC2, and so on

library(scatterplot3d)
scatterplot3d(T1_nipals,T2_nipals,T3_nipals)

scatterplot3d (T1_nipals,T2_nipals,T3_nipals,
+pch=16,highlight.3d=TRUE,type="h")

We can draw also this plot and rotate it with the mouse to get the orientation we prefer.
library(rgl)
plot3d(T1_nipals,T2_nipals,T3_nipals,col="red",size=5)

 
Another nice plot that we can rotate with the mouse is this one:
library(Rcmdr)
scatter3d(sflw.msc3.tra$G00rmn,T2_nipals,ç
+ T3_nipals,surface=FALSE,grid=FALSE)
 
In this case one of the axes is the constituent, and we can see the patterns of correlation between the constituent and the scores.
If interested in this type of plots, you can read the post: 3D plots in R from the Revolution blog.
 
Once we have our PCA space, objects can be projected into the PCA  space, the distance from the object to  this projection is the orthogonal distance (O.D.), this projection will have a score distance (S.D), respect to the center and for every PC.
We can have three kinds of situations:
  1. Large O.D. but short S.D
  2. Large O.D and large S.D. (Bad leverage point)
  3. Short O.D and large S.D. (Good leverage point)
It is important a plot to detect this type of outliers, and to fix some limits for detection.
pcaDiagplot(sflw.msc3.tra$NIRmsc,X.pca=X_nipals,
+ a=4,pch=c(20:24)[sflw.msc3.tra$Operator],
+ col=c("red","blue","green","brown")

+ [sflw.msc3.tra$Operator])
 
In the table of distances, we can check the outliers for the O.D and S.D. We have three samples which have a large OD and a large SD at the same time (14,80,87), two samples with a large OD but the SD into the limits (79,85), and two samples with a large SD, but the OD is into the limits (19,86).

outliers<-sflw.msc3.tra$NIRmsc[c(14,80,87,79,85,19,86),]
matplot(wave.NIR,t(outliers),type="l",lty=1,xlab="nm",

+ ylab="log 1/R")


 

No hay comentarios:

Publicar un comentario