Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.