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 detect outlier is the “Mahalanobis distance”. And we are going to calculate the Mahalanobis distance to the center of the population.

Previously we have calculated with the NIPALS algorithm the T score matrix, for three PCs.

Let´s calculate now the Mahalanobis distance (Library: Chemometrics) for a certain probability.

**
**

**
****> Moutlier(T3pc_nipals,quantile =0.975, plot=TRUE)**

**$md **

[1] 3.4506943 2.0677806 1.8554593 1.3493939 1.0093176 1.4537839 1.7177865

[8] 0.8551981 1.9936152 1.7136093 1.6755040 1.0370122 0.6980203 1.0457686

[15] 1.9107813 2.4836284 1.8483303 1.6226210 1.7422189 2.3278939 2.9407373

[22] 1.0270963 0.8200505 1.3194672 1.0637166 0.7383098 0.9658263 1.1470021

**$cutoff**

**[1] 3.057516**

We can see how the sample number “1” is out of the cutoff ratio.

*Related*

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

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...

**Tags:** "R" Chemometrics