Blog Archives

"NIR Std. Dev. Spectra" with "R"

February 15, 2012
By
"NIR  Std. Dev. Spectra" with "R"

(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...

Read more »

"R" PLS Package: Multiple Scatter Correction (MSC)

February 12, 2012
By
"R" PLS Package: Multiple Scatter Correction  (MSC)

MSC (Multiple Scatter Correction) is a Math treatment to correct the scatter in the spectra. The scatter is produced for different physical circumstances as particle size, packaging.Normally scatter make worse the correlation of the spectra with the constituent of interest.Almost all the chemometric software’s available include this math treatment and of course “R” have it as well in the...

Read more »

"R": Predicting a Test Set (Gasoline)

February 9, 2012
By
"R": Predicting a Test Set (Gasoline)

> data(gasoline)> #60 spectra of gasoline (octane is the constituent) > #We divide the whole Set into a Train Set and a Test Set.> gasTrain<-gasoline> gasTest<-gasoline> #Let´s develop the PLSR with the Tain Set ...

Read more »

"R": PLS Regression (Gasoline) – 005

February 8, 2012
By
"R": PLS Regression (Gasoline) – 005

Let´s see know how to plot the scores for the 3 PLS Components:  We can see the explained variance from each component in the diagonal.We can get it from R with:> explvar(gas1)   Comp 1      Comp 2  &nbs...

Read more »

"R": PLS Regression (Gasoline) – 004

February 7, 2012
By
"R": PLS Regression (Gasoline) – 004

In the previous post we plot the Cross Validation predictions with:> plot(gas1, ncomp = 3, asp = 1, line = TRUE)We can plot the fitted values instead with:> plot(gas1, ncomp = 3, asp = 1, line = TRUE,which=train) Graphics are different:Of course, using "train" we get  overoptimisc statistics and we should look...

Read more »

"R": PLS Regression (Gasoline) – 003

February 3, 2012
By
"R": PLS Regression  (Gasoline) – 003

The gasoline data set has the spectra of 60 samples acquired by diffuse reflectance from 900 to 1700 nm. We saw how to plot the spectra in the previous post.Now, following the tutorial of Bjorn-Helge Mevik published in "R-News Volume 6/3, August 2006", we will do the PLS regression:gas1 <- plsr(octane~NIR, ncomp = 10,data = gasoline, validation...

Read more »

"R": Plotting the spectra (Gasoline) – 002

February 2, 2012
By
"R": Plotting the spectra (Gasoline) – 002

"R" has a package called "ChemometricsWithR", where we can get data from different analytical instruments including Near Infrared (NIR).Follow the steps to plot the spectra of a gasoline data set:In this other case we plot the spectra of the NIR shootout 2002: > data(shootout)> wavelengths<-seq(600, 1898,by=2)> mattplot(wavelengths,shootout$calibrate.1,xlab="wavelength(nm)",ylab="log1/R)")>...

Read more »

"R": Looking at the Data (Gasoline) – 001

February 1, 2012
By
"R": Looking at the Data (Gasoline) – 001

As other softwares "R" has nice tools to look to the data before to develop the calibration.Statistics for the "Y" variable (in this case octane number) like Maximun, Minimun,..,standard deviation,...are important:> library(ChemometricsWithR)> data(gasoline)> summary(gasoline$octane)   Min.  1st Qu.  Median    Mean   3rd Qu.    Max.   83.40   85.88    87.75    87.18   88.45    89.60> sd(gasoline$octane) 1.530078And of course the Histogram:> hist(gasoline$octane)

Read more »

NIPALS: Principal Components Analysis with "R" (Part: 002)

January 1, 2012
By
NIPALS: Principal Components Analysis with "R" (Part: 002)

We started some posts based on the tutorials of:"Multivariate Statistical Analysis using the R package chemometrics"The first post was:Principal Components Analysis with "R" (Part: 001)Now we continue with a second part.The graphics help us to dec...

Read more »

IRIS Flower Data Set (R-003)

December 19, 2011
By
IRIS Flower Data Set (R-003)

Centramos la matriz con el comando, generando a partir de A una nueva matriz que llamamos "Acentered"Acentered=scale(A,center=T)Ahora con la función "eigen":Esta es otra forma de proceder con el cálculo de los componentes principales (eigenvectors y ...

Read more »