20 ene. 2018

Analyzing Soy meal in transmitance (part 2)

This is the second of the posts about analyzing soy meal unground in an Infratec, adding the sample directly to the conveyor in the same way that we do with wheat or barley. The range wavelength in the Infratec is from 850 to 1050nm, in steps of 2 nm, so we have a total of 100 data points.

Once we have decided one of the math treatments to work, we can apply a Principal Components analysis to the data. This way we can understand better the structure of the data.
X_msc_prcomp<-prcomp(X_msc)

This way we obtain two importan matrices, the score matrix and the loadings matrix (We have been talking about this matrices in other posts).
In this post we are going to check the loadings that we can see graphically in two ways: as spectra or in the Principal Component space.
If we want to se them as spectra (first three loadings), run this script in R:
>matplot(wavelengths,X_msc_prcomp$center,type="l",
 xlab="wavelengths",ylab="transmitance")
Or we can see them in the Principal Components space, were we can see the range of variation
and this is the script for this last plot:
 par(mfrow=c(1,2),pty="s")
 offset<-c(0,0.09) # to create space for labels
 plot(X_msc_prcomp$rotation[,1:2],
      type="l",xlim=range(X_msc_prcomp$rotation[,1])+offset,
      xlab="PC1",ylab="PC2")
 #identify(X_msc_prcomp$rotation[,1:2])
 points(X_msc_prcomp$rotation[c(33,64,100),1:2],pos=4)
 text(X_msc_prcomp$rotation[c(33,64,100),1:2],pos=4,
      labels=paste(c(914,976,1050),"nm"))

offset<-c(-0.05,0.25) # to create space for labels
plot(X_msc_prcomp$rotation[,2:3],type="l",
     xlim=range(X_msc_prcomp$rotation[,1])+offset,
     xlab="PC2",ylab="PC3")
#identify(X_msc_prcomp$rotation[,2:3])
points(X_msc_prcomp$rotation[c(33,64,100),2:3],pos=4)
text(X_msc_prcomp$rotation[c(33,64,100),2:3],pos=4,
     labels=paste(c(914,976,1050),"nm"))
 
 


No hay comentarios:

Publicar un comentario