We have seen (Selecting samples for lab analysis - Part 1), how to select a wide and flat distribution of spectra from a wide amount, in order to send to the laboratory and develop a calibration according to our resources, but in case we can assume to send some more for the validation, we can use the function "duplex", from "prospectr package", and select at the same sample another set of samples "test" to evaluate the model.
We can use Euclidian or Mahalanobis distance for the calculation and the number of PCs that we consider.
library(prospectr)dup<-duplex(X=X,k=20,metric="mahal",pc=3)
par(mfrow=c(3,1),ps=14)
plot(dup$pc[,1],dup$pc[,2],xlab="PC1",ylab="PC2")
points(dup$pc[dup$model,1],dup$pc[dup$model,2],pch=19,col="red")
points(dup$pc[dup$test,1],dup$pc[dup$test,2],pch=19,col="blue")
plot(dup$pc[,1],dup$pc[,3],xlab="PC1",ylab="PC3")
points(dup$pc[dup$model,1],dup$pc[dup$model,3],pch=19,col="red")
points(dup$pc[dup$test,1],dup$pc[dup$test,3],pch=19,col="blue")
plot(dup$pc[,2],dup$pc[,3],xlab="PC2",ylab="PC3")
points(dup$pc[dup$model,2],dup$pc[dup$model,3],pch=19,col="red")
points(dup$pc[dup$test,2],dup$pc[dup$test,3],pch=19,col="blue")
In "Red" are the samples selected for the Calibration, and in "Blue" the samples selected for the Validation, from different perspectives (maps of scores).
No hay comentarios:
Publicar un comentario