Standard Normal Variate (SNV: Other way)

January 1, 2013

(This article was first published on NIR-Quimiometria, and kindly contributed to R-bloggers)

This is another way to pre-treat aspectra set with the SNV math-treatment
 (Standard Normal Variate). You can see the other one in the post :
In this post, I use the R function “sweep“.
#in a first step I calculate the average value
#of all the data points for every spectrum and
#subtract it to every data point of the
#spectrum using the function “colMeans”
#from the package “ChemometricsWhithR”
#the mean value for every spectrum is now cero.
#sd function calculates the SD for all the data
#points of every #spectrum.
#We divide now the value of every data point
#by the SD of all the values of that spectrum.
#Now the spectrum has a mean of cero and a SD of 1.
#Use matplot to plot the spectra. 
+xlab=”nm”,ylab=”log 1/R”,
+main=”SNV Gasoline Spectra”,col=”blue”)
We have to take consider that in the Gasoline matrix, the rows are the
samples and the columns the wavelengths, so we have to transpose the matrix
for some calculations.
Gasoline is a data set included in the “pls” package. Is not a set to see the benefits
 of the SNV math treatment (not enough scatter), but you can try
with other data sets as “yarn”.

To leave a comment for the author, please follow the link and comment on their blog: NIR-Quimiometria. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)