# Looking to the difference spectrum

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**NIR-Quimiometría**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

From the

**previous post**, we can make the difference spectrum (once the samples are sorted by moisture) between the sample with the lowest moisture value (position 1), from the sample with the highest moisture value (position 66). This spectra will help us to understand where are the band positions (should be positive) for the moisture. Of course other bands will appear, because these two samples have different values for the other constituents, so we must be careful with this.It is important to know the inter-correlations between the different constituents.

I multiplied the difference spectra by 10, in order to see better the bands.

**min_moi<-moiNIR_msc$NIRmsc[1,]**

**max_moi<-moiNIR_msc$NIRmsc[66,]**

**diff_moi<-max_moi-min_moi**

**diff_moi10<-ext_moi*10**

**mix_moi<-rbind(min_moi,max_moi,diff_moi10)**

**matplot(wave_nir,t(mix_moi),lty=1,pch=”.”,**

**+ xlab=”wavelength”,ylab=”log(1/R)”)**

We can see two big positive bands at 1940 nm (combination band), and other at 1450 nm (1º overtone) due to the water.

We can do the same procedure with other math treatments, but the spectra can be more difficult to interpret.

The difference spectra will help us to understand better the loadings spectra.

To

**leave a comment**for the author, please follow the link and comment on their blog:**NIR-Quimiometría**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.