(This article was first published on

**NIR-Quimiometría**, and kindly contributed to R-bloggers)It is always good to look at the spectra from different points of view, before to develop a regression, this will help us to understand better our samples, to detect outliers, to check where the variability is, if that variability correlates with the constituent of interest (directly or inverse),…..

Chemometric software’s have the tools to do it.

A single tool to check our spectra is the standard deviation spectrum where every data point has the standard deviation value for the absorbances at every wavelength,. This SD spectrum is a nice way to see where the variability is, so we can understand better the importance of the wavelengths in other calculations as the principal components, loadings,….

In the previous post we have seen how to apply MSC (Multiple Scatter Correction) to the NIR Spectra (Yarn) with "R".

To understand better the effect of this math treatment, we can have a look to the standard deviation spectra.

For this post, the idea is a simple exercise to over plot the “standard deviation spectra” of the Yarn NIR Data (from the PLS package) "with and without" the MSC (Multiple Scatter Correction) applied.

**> sd_spec<-sd(yarn$NIR)**

**> yarn_msc<-msc(yarn$NIR)**

**> sd_mscspec<-sd(yarn_msc)**

**> sd_overplot<-cbind(sd_spec,sd_mscspec)**

**> wavelength<-c(1:268)**

**> matplot(wavelength,sd_overplot,lty=1,pch=21,**

**+ xlab="data_points",ylab="std dev")**

To

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

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...