Let´s work with the principal components analysis (PCA) with the "datsoilspc" spectra with the math treatment SNV and Detrend. This time we use the Caret package:
library(caret)
spc_snvdt_pca<-preProcess(spectra_snvdt,
method = c("center", "scale","pca"),
thresh = 0.95)
PC_scores<-predict(spc_snvdt_pca,spectra_snvdt)
plot(PC_scores[,1],PC_scores[,2],col="blue",
xlim=c(min(PC_scores[,1]),max(PC_scores[,1])),
ylim = c(min(PC_scores[,2]),max(PC_scores[,2])),
xlab = "PC1",ylab = "PC2")
To explain the 95% of the variance Caret recommends 5 factors, so we can see the scores maps of every factor versus the others, like in this case PC1 vs. P2.
These maps are useful to see the distribution of the samples in the Principal Component space, to check if we have outliers, detecting groups,....
The explained variance is increasing as we add more PCs, but we have to decided a cutoff for the number of PCs.
It is interesting to look to the projections of the samples on every component, and the distance from the projection to the center is the score of the sample for every PC.
First two PCs in this figure can be seen with the previous one to see a small group and a probably outlier. Anyway we have to consider the other three.
No hay comentarios:
Publicar un comentario