(This article was first published on

**NIR-Quimiometría**, and kindly contributed to R-bloggers)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: Oleic Acic (C18:1).

Of course we are going to use the MSC pretreatment. For vcross validation we are going to use “leave one out”.I decide a maximum of 16 PLS terms.

**> C18_1<- plsr(C18_1~NITmsc, ncomp = 16,data =fattyac_msc,**

**+ validation = "LOO")**

**> plot(C18_1,ncomp=12,which="validation")**

We can see how from Term 12 the RMSEP increase.

We can see in the XY plot, how we have a few samples with a high residual (probably wrong lab value for one or two of them). We can delete these samples from the data set to develop the equation again (RMSEP will decrease a little bit and the RSQ will increase)

We have to consider the Lab error for this parameter of the reference method: Chromatography.

The extreme sample 66, fits well in the model, so we decide to keep it. The model seems quite good to predict “Oleic acid”. We will test it in a near future with new samples (independent test set).

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