Publications by jrcuesta

"R": PLS Regression (Gasoline) – 004

07.02.2012

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 better at the Cros...

2691 sym 6 img

"R": PLS Regression (Gasoline) – 005

08.02.2012

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     Comp 3     Comp 4     Comp 5     Comp 6 70.9656438  7.5943956  7.5871843  9.2537926  0.7201960  0.8472951    Comp 7...

1433 sym 10 img

"R": Predicting a Test Set (Gasoline)

09.02.2012

> data(gasoline)> #60 spectra of gasoline (octane is the constituent) > #We divide the whole Set into a Train Set and a Test Set.> gasTrain> gasTest> #Let´s develop the PLSR with the Tain Set and LOO CV> gas1> summary(gas1)Data:   X dimension: 50 401         Y dimension: 50 1Fit method: kernelplsNumber of components considered: 10VALIDA...

2785 sym 4 img

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

12.02.2012

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

1531 sym 6 img

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

15.02.2012

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

1696 sym 4 img

NIR "Cross Validaton Statistics" with "R"

16.02.2012

We have to check different options before to decide for one model:Configure different cross validations.Configure different math  treatments.Configure number of terms.With the Yarn NIR data, I have develop 4 models, for a simple exercise.Of course we can check many combinations.As math treatment I choose the raw spectra and the spectra treated w...

1975 sym 4 img

Plotting the “Mean Spectrum”

17.02.2012

Mean spectrum calculation is important: To center a matrix of spectra, we subtract the mean spectrum, from every spectrum in the matrix. There are also many options to use the mean spectrum, like average subsamples. Let´s calculate and plot the mean spectra for the Yarn NIR Data: > yarn_mean > wavelength > matplot(wavelength,yarn_mean,lty=1,pch...

874 sym 6 img

Standard Normal Variate (SNV)

19.02.2012

This is another pretreatment used quite often in Near Infrared to remove the scatter. It is applied to every spectrum individually. The average and standard deviation of all the data points for that spectra is calculated. Every data point of the spectra is substracted from the mean and divided by the standard deviation. “R” has a function to...

1088 sym 6 img

PCA for NIR Spectra_part 001: "Plotting the loadings"

22.02.2012

There are different algorithms to calculate the Principal Components (PCs). Kurt Varmuza & Peter Filzmozer explain  them in their book: “Introduction to Multivariate Statistical Analysis in Chemometrics”.I´m going to apply one of them, to the Yarn spectra.Previously we have to center the X matrix, let´s call it Xc.> XcThe algorithm I´m go...

1206 sym 4 img

PCA for NIR Spectra_part 002: "Score planes"

23.02.2012

The idea of this post is to compare the score plots for the first 3 principal components obtained with the algorithm “svd” with the scores plot of  other chemometric software (Win ISI in this case). Previously I had exported the yarn spectra to this software.Let´s first use the command “pairs”, to see in “R” the score plots for the...

934 sym 6 img