Publications by jrcuesta

PCA for NIR Spectra_part 003: "NIPALS"

25.02.2012

> X> X_nipalsnipals(X,a=10,it=100)Two matrices are generated (P and T)As in other posts, we are going to look to the loadings & scores, for firsts three principal components:> wavelengths> matplot(wavelengths,X_nipals$P[,1:3],lty=1,  + pch=21,xlab=”data_points”,ylab=”log(1/R)”)> T3cpT[,1:3]> pairs(T3cp)In the following plot, I compare th...

1017 sym 10 img

PCA for NIR Spectra_part 004: "Projections"

26.02.2012

This plot in 2D, help us to decide the number of PCs, it is easy to create in R, once we have discompose the X matrix into a P matrix (loadings) and a T matrix (scores).For this plot, we just need the T matrix.> CPs>  matplot(CPs,t(Xnipals$T),lty=1,pch=21,  + xlab=”PC_number”,ylab=”Explained_Var”)Every dot for every vertical line repre...

1296 sym 4 img

PCA for NIR Spectra_part 005: "Reconstruction"

27.02.2012

We saw how to plot the raw spectra (X), how to calculate the mean spectrum, how to center the sprectra (subtracting the mean spectrum from every spectra of the original matrix X). After that we have developed the PCAs with the NIPALS algorithm, getting two matrices: T (scores) and P (loadings).We have to decide the number of PCs, looking to the ...

1504 sym 6 img

PCA for NIR Spectra_part 006: "Mahalanobis"

28.02.2012

Outliers have an important influence over the PCs, for this reason they must be detected and examinee.We have just the spectra without lab data, and we have to check if any of the sample spectra is an outlier ( a noisy spectrum, a sample which belongs to other population,……., an extreme sample for a particular constituent,..).One way to detec...

1489 sym 4 img

NIT: Fatty acids study in R – Part 001

01.03.2012

This time I´m going to use my own data to develop a model to predict some fatty acid in the solid fat (pork).Samples had been analyzed in a NIT (Near Infrared Transmittance) instrument. The range of the wavelengths is from 850 to 1048 nm (100 data points). This area cover usually second overtones.I am quite novice in R, and it takes some time (i...

1617 sym 6 img

NIT: Fatty acids study in R – Part 002

02.03.2012

> library(chemometrics)> fatmsc_nipals> CPs> matplot(CPs,t(fatmsc_nipals$T),lty=1,pch=21,  + xlab=”PC_number”,ylab=”Explained_Var”)In the 2D plot, we can see that with 3 or 4 principal components, almost all the variance is explained. We see also how samples are well projected over the first PC, but how one sample seems to be an outlier ...

3757 sym 8 img

NIT: Fatty acids study in R – Part 003

05.03.2012

As I told you I´m a beginner in “R”, so I realize that I have to prepare my data a little bit in order to continue from my previous post ( NIT: Fatty acids study in R – Part 002) after getting some errors. Anyway I´m really fascinated with this program, so sorry if I make some confusion.> fattyac_msc+ C18_1=I(C18_1),C18_2=I(C18_2),C18_...

1872 sym 8 img

NIT: Fatty acids study in R – Part 004

07.03.2012

It is clear that MSC does not remove the entire scatter in the raw spectra, so some of the information is hidden by the scatter. Improvement of the sample presentation will help to remove the scatter.We know that the first loading is much related to the main source of variance (in this case the scatter). In the next figure, I overplot the standar...

3028 sym 10 img

NIT: Fatty acids study in R – Part 005

09.03.2012

There are several algorithms to run a PLS regression (I recommend to consult the books: “Introduction to Multivariate Analysis in Chemometrics – Kurt Varmuza & Peter Filzmozer” and “Chemometrics with R – Ron Wehrens”).We are going to use the PLS package, and we are going to develop, maybe the constituent which looks more promising: Ol...

1605 sym 6 img

NIT: Fatty acids study in R – Part 006

12.03.2012

In one of the columns, for constituent C16_0, one sample (57) has a value of “zero” (we could see this in the histogram).The reason for that is that the laboratory did not supply this value. The PLS regression will consider the lab value as cero, so we will get a plot like this:I observed also that the sample 219 has a high residual for the r...

2135 sym 8 img