30 ene. 2012

Updating the equation

We have new data to update the calibration for a pet food category.
 This data comes has been kept from different validations, and we decide that is time to update the calibration from different reasons (we have new variability: new batches, new formulation,….).
After looking at the spectra (searching for X outliers).We divide again the data set into validation and calibration sets, an develop different calibrations for each constituents in search of the best math treatment, more or less terms,….., which treatment take out less outliers, which more,….
Take notes, find answers and conclusions:
This is an example for the protein:
Important to look at the SEV (standard error of validation) we get for the Validation Set chosen randomly, and the other statistics.
Think that in a normal case:
After this study, mix again validation and calibration samples and develop the calibration (for each constituent) with the settings you found better. Probably this option increase change the number of terms, and of course will change the statistics.

After all the calibrations are developed, compare the new statistics with the ones of the previous equations.
Statistics can improve or even to be worse. Think why:
Look at the Mean and Std. Dev.     
In this case I´m quite happy because I got a good improvement in the ash constituent. But the others have new variability and more samples and that is also very important.

Install the calibration in routine, and store new samples for the next validation.

Make a control chart (residual vs. lab value) meanwhile to control the calibration.

25 ene. 2012

NIR: Post-dispersive concept

En un "post" anterior, vimos como trabaja un equipo FTIR, con el concepto de interferómetro de Michelson. En este vídeo, vemos el funcionamiento de un NIR dispersivo y para ser mas concreto post-dispersivo.
Esta es una breve descripción:
Una lámpara halógena envía luz policromática que ínter-actúa con la muestra. La luz reflejada es recogida por diversas fibras ópticas que se unen para focalizar la luz reflejada en la red de difracción. La red de difracción, se mueve y envía luz monocromática a los detectores y la electrónica envía el espectro al ordenador.
Otros equipos, se denominan pre-dispersivos, en este caso la radiación policromática de la lámpara incide primero en la red de difracción para ser descompuesta en luz monocromática y ser enviada a traves de una rendija y una serie de filtros a la muestra. La luz reflejada en la muestra incide ya directamente sobre los detectores.

In a previous post we saw the fundamentals about how a FTIR works. In this one we can see how a dispersive instrument works. To be more concrete it is a post-dispersive instrument.
This is a brief description:
Polychromatic light (coming from a halogen lamp through optic fiber) interacts with the sample. Reflected light goes to the grating via several optic fibers which collect reflected light and focused it into the Grating.
Grating movement generates monochromatic light which is focused into the detectors. Electronics produces the spectrum.
Other NIR instruments are called pre-dispersive, in this case the lamp polychromatic radiation first strikes the  grating to be decomposed into monochromatic light and sent through a slit and some filters to the sample. The reflected light from the sample is collected directly by the detectors.

23 ene. 2012

Looking at the Spectra: Outliers_001

These are samples of a type of fat (liquid) meassured in transflectance, to develop a calibration for moisture. In the first figure we can see 3 samples which clearly are of high moisture content and clearly separate from the rest. Anyway the lab value for these samples does not make sense, because it´s lower than many of the other samples in the set.
If we take out this 3 samples the correlation plot improve at 1450 nm from 0,50 to 0,70.
We found similar problems in not such a big scale for some of the other samples, anyway I develop the equation with a simple math treatment. We can get better improvement with more complex ones, or not, validation will decide.
Some outliers (5) have been remove for high residual probably for the reason I was talking about.
We split data into a calibration and a validation set (ramdomly)
Calibration Plot and statistics:

Validation statistics:
Standard error of prediction (SEP) is almost similar to SECV(Standard error of cross validation).
I used a simple Multiple Scatter Correction math treatment without derivatives, so more combinations can be tried.
When this happens, ask to the lab for the values, review the papers,....,trying to get the right values.
It´s important how much time has passed from the acquisition of the spectra and the lab reference analysis.
Do we keep the sample  to repeat the reference analysis ad sample acquisition?

Think in more causes,......

21 ene. 2012

VIDEO: Suma de Matrices (otra manera)

Esta es otra manera de realizar la suma de matrices en Excel. Os recomiendo seguir los tutoriales de la "Russian Chemometric Society", son realmente útiles.
This is another way to add matrices in Excel. I really recommend to follow the tutorials of the "Russian Chemometric Society", they are really helpful.

Looking at the spectra (Wheat / Flour / Starch)

This is another post, to exercise the visualization of the spectra, the NIR bands, mathematical treatments,…..etc.
Starch and gluten are major constituents in wheat, and therefore flour. Wheat starch is used as an excipient in the pharmaceutical industry; on the other hand, the gluten is the major protein of wheat (about 80% of total protein).
I do not have a spectrum of gluten, but for this exercise I have overplot spectra of wheat, flour and starch.
Red spectra is the spectra of "wheat starch" (range of 1100-2500 nm), blue of "wheat flour" (range of 400-2500 nm) and green spectrum "wheat" (range of 400-2500 nm).
Let's see, therefore, the spectral region common to the three: 1100-2500 nm.
If we do not apply any mathematical treatment, the particle size obviously gives these separations on the scale of intensity, which is not a good way to compare them.

Let´s apply a second derivative math treatment, where we can find some better conclusions.

One of the reasons of this exercise is to understand better the developments of calibrations for protein in wheat flour, developed by Osborne et al. where the absorption band at 2100 nm for the starch is used because is interfering with the protein band (gluten) at 2180 nm. Water is of course another major constituent and has an absorption band at 1940 nm, which interfere with the other wavelengths. Osborne et al. used as well, a neutral wavelength (1680 nm) in order to correct the effect of particle size in the sample.
With these four wavelengths (four filters in an instrument) an MLR calibration was developed.

17 ene. 2012

Working in transflectance

Sample presentation in Near Infrared can be done in reflectance or in transmission. There are modules to work in each of them or in both. In reflectance the light goes through the sample and interacts with it and part of this light returns to the detectors (we don´t know the pathlength).
We cannot measure certain liquids this way (like water, oil,…) because light will goes through and did not return to the detectors, so we need to put behind the sample a reflector, so the light cross the sample, is reflected on the reflector´s surface and cross the sample again to the detectors. This way to analyze is called “transflectance”.
There are reflectors of different pathlengths (0.1mm, 0.2mm, 0.5mm,….), beeing this measurement  the gap between the glass of the cuvette and the surface of the mirror. So the real pathlength the light goes through is two times this value.
The pathlength must be choosing depending of the absortibity of the sample. If the water content is high we have to choose probably 0.1mm. For other samples (without or with few water) 0,5mm can be fine.
If we have a transmission module, this option is not necessary, and we use othe types of cuvettes which we will talk in future posts.

NIR bands positions for fat (Fish meal / Fish oil)

Podemos ver en la figura espectros de "harina de pescado" (arriba) y de "aceite de pescado" (abajo). En ocasiones  representar de manera conjunta espectros de dos productos diferentes noa ayuda a entender mejor la información sobre las posiciones de la banda NIR (en este caso las bandas de grasa).
Conocer la posición exacta e intensidad de las bandas, es importante para saber si están relacionadas con ácidos grasos saturados o insaturados.
Para comprobar mejor la posición de las bandas se puede utilizar la primera derivada en busca de los cruces por cero, o la segunda derivada en busca de los picos negativos.

We can see in the figure the spectra of “fishmeal” (up) and “fish oil” (bottom). Sometimes is better to over plot these spectra from two different products to understand better the information about the NIR band positions (in this case the fat bands).
To know the exact position of the bands is important in order to know if the bands are due to saturated or unsaturated fatty acids.
Also their intensity gives to us clues about the type of oil.

To check better the position of the bands we can use the first derivative looking for the zero crossings, or the second derivative looking for the negative peaks.

En el espectro de aceite de pescado (en negro), las bandas se encuentras a: 1714, 1764, 2140, 2306 y 2346 nm.
Estas características sbre la posición de las bandas, permiten discriminar entre tipos de aceites (palma, pescado, soja, girasol, maíz, colza,....).
Conocer las posiciones de las bandas, nos ayuda también a realizar mejores regresiones (bien acotando el rango de longitudes de onda, o seleccionando las longitudes de onda en una regresión MLR), y a interpretear mejor los espectros de coeficientes de regresión.

In this fish oil spectra (black one) we can find bands at: 1714, 1764, 2140, 2306 and 2346 nm.
These characteristics of the bands position makes NIR useful to discriminate types of oils (fish, palma, sunflower, soya, corn, rape,…..).
To know well the position of the bands help us to make better regressions (trimming the spectra to the interesting wavelength range, or selecting wavelengths for the MLR regression), also to interpret better the coefficients regression spectrum.

15 ene. 2012

Russian Chemometric Society

Thanks a lot to the Russian Chemometric Society for the link to this blog. I really appreciate. Their Web page is really for me an important source of information and knowledge.

Muchas gracias a la Russian Chemometric Society por la información sobre este blog. Disponen de una página Web que será para mi sin duda fuente de información para los futuros “posts” de este blog.

VIDEO: Matriz transpuesta en Excel (2)

14 ene. 2012

RUSSIA: Eighth Winter Symposium on Chemometrics

During the lasts months the number of visits from Russia to this blog has increase significantly. I found this interesting event in Russia, that I would like to promote from here.

The following text is from the Webpage:

Eighth Winter Symposium on Chemometrics
You are cordially invited to attend Eighth Winter Symposium on Chemometrics — the only chemometrics conference in Russia. The symposium will be held at the picturesque recreation center, Drakino, located 100 km south of Moscow. Attendees will live in comfortable single and double rooms. The total number of participants is limited to 80 persons due to the small size of the resort.
The symposium program includes invited lectures, as well as submitted oral presentations and posters. The contributions may report mature results, feasibility studies, or problem discussions etc. A friendly and open-minded atmosphere is a distinguishing feature of all WSC meetings. The official symposium language is English.
Presenters of mature works will be encouraged to submit manuscripts through the organizers for publication together in Chemometrics and Intelligent Laboratory Systems, subject to the normal peer review process.
An introductory school on chemometrics traditionally will be held immediately before the symposium. The participants of the school will be introduced to projection methods of multivariate data analysis, multivariate calibration and classification. The course language is Russian.

Scope and Themes
Winter Symposium on Chemometrics (WSC) is an international scientific event held under the aegis of the Russian Chemometrics Society. It covers a wide area of modern methods and applications of multivariate data analysis, including quantitative and qualitative analysis, PAT, theory of sampling, experimental design, image analysis, QSAR/ QSPR, and others.
From the beginning, the organizers have attempted to achieve, and hopefully attained, an optimal balance between theoretical aspects of data analysis and their practical applications. The conference brings together both academic scientists and industrial experts, providing many opportunities for personal contacts and fruitful discussions.
Traditionally, WSC is very friendly to young scientists and those beginning to carve their way in data analysis. Students’ research works neighbor presentations of experienced chemometricians. Since 2005 special prizes to the best poster and the best talk presented by young(er) participants have been awarded.
WSC is the first and the only conference on chemometrics in Russia. The conference was created as a part of the Drushbametrics project established about 10 years ago by a small group of enthusiasts from Russia and Scandinavia. The main objectives of Drushbametrics were dissemination and popularization of chemometrics in Russia, as well as establishment of a bridge connecting Russian scientists to the international chemometric community. During seven previous conferences held in Russia since 2002, WSC has been recognized internationally for its solid scientific content and intensive social program.
The social and cultural program is what makes the conference unique. Each conference day is concluded with the famous “Scores & Loadings” gathering where communication continues in a less formal manner.

NIR: Remote Reflectance Probe

This is a reflectance probe. The probe´s head is placed over the sample (fish, ham,cheese,....). In the video you can see the part of the probe which is in contact with the sample.
1) the sample is acquired: See in the video how the plate with the reference moves out of the path so the ligth comes from the slit into the sample (in this case no sample). Light will interact with the sample and diffuse reflectance goes to the detectors (in both sides of the slit) which are in a special geometry to receive as much diffuse reflectance as possible. The spectrum of the sample is stored (sample file).
2) the reference is acquired: The ceramic moves into the light path (the ceramic  is looking to the slit in the other side of the plate).The spectrum of the reference is stored (reference file).
3)Reflentace is calculated.
3) Log (1/R) file is calculated: log(1/R) = -log (Sample file / Reference file).

Video: Suma de Matrices en Excel

Me he animado a hacer un nuevo video, trata de como sumar matrices en Excel, siempre que cumplan con el requisito de suma. Obviamente es el mismo método para la resta.

Propiedades de la Suma de Matrices:
(A+B)+C = A+(B+C)
A+B = B+A
A+0 = A
A + (-A) = 0

Video: Middle Infrared (MIR) Theory Fundamentals.

This is a nice video which talks about the fundamentals of Infared Spectroscopy (in this case Middle Infrared – MIR).
We have to take into account that in the Near Infrared appear the overtones and combination bands of the bands we see in the MIR spectrum.
A good knowledge of the Middle Infrared will help us to understand and interpret better the NIR spectrum.

13 ene. 2012

Signal to Noise Ratio

Hemos hablado en el "post anterior" de analizar el espectro del talco un número determinado de veces y calcular la desviación estandar de los valores de absorción, a este valor la llamamos el ruido (N).
Por otra parte calculamos el valor medio de absorción de todas las medidas (S). Dividiendo este valor entre el ruido, obtenemos la relación señal ruido (S/N).
Karl Norris publico un artículo (con 20 repeticiones de una muestra de talco analizadas en un equipo NIR) en la American Pharmaceutical Review, obteniendo un valor medio (S) de absorción de 0,0739. La desviación estándar (N) fue de 57,3 microA, por tanto:
We talked in the previous post, to analyze the spectrum of talc a certain number of times and calculate the standard deviation of absorbance values ​​of the diferent measurements, at this value we call it noise.
On the other hand we calculate the average value of absorption of all the measures. Dividing this value by the noise, we get the signal to noise ratio (S / N).
Karl Norris published an article (with 20 repetitions of a sample of talc analyzed in a NIR) in the American Pharmaceutical Review, obtaining an average value (S) of  0.0739 Abs. The standard deviation (N) was 57.3 microAbs, so:

 S/N = 0,0739 : 0,0000573 =1290

12 ene. 2012

Talc Spectrum / Espectro de Talco (part 1)

"Talc acts as both a glidant and lubricant during tableting, and as a polishing agent for tablet coatings. Talcs are chemically inert, oleophilic and hydrophobic, and have relatively high oil absorptions. Being the softest mineral, by definition as 1 on Moh’s scale of hardness, talcs have very low abrasion, protecting expensive tablet dies and other machine parts." (Specialty Minerals).

Este es el espectro NIR del talco. Se trata de un espectro muy interesante por la banda aislada  que presenta  a 1392 nm aproximadamente. Esta banda es ampliamente utilizada en muchos estudios de diagnósticos de un equipo NIR como son la repetibilidad y la resolución.
Podemos realizar el análisis de la muestra en un número determinado de ocasiones, anotando el valor de absorción del equipo en cana uno de ellas y posteriormente realizar la desviación estándar, para calcular la precisión.
La intensidad de esta banda aumentará o disminuirá también según sea la resolución de los equipos. No obstante tenemos que tener en cuenta que la repetibilidad también será mejor o peor en función de la resolución y por tanto de la intensidad de la banda.
Por tanto aquí se presenta un dilema: ¿Queremos una mayor intensidad de la banda? o ¿Queremos una mayor repetibilidad?.
Esta claro que las dos opciones tienen sus ventajas, pero debemos de tener en cuenta que la precisión es de gran importancia a la hora de cualificar o cuantificar la repetibilidad es muy importante. No obstante a la hora de detectar trazas de esta banda (de la presencia de talco) el aumento de la resolución nos ayudará.

This is the NIR spectrum of talc. This is a very interesting spectrum for the isolated band presented at 1392 nm. This band is widely used in many studies of NIR instrumentation such as repeatability and resolution.
We perform the analysis of the sample in a certain number of occasionsand then we make the standard deviation of the absorbance values obtained to calculate the precission.
The intensity of this band also increase or decrease according to the resolution of the equipment. But we must know that the repeatability will also be better or worse depending on the resolution and therefore the intensity of the band.
So here is a dilemma: Do we want a greater intensity of the band? or Do we want a better repeatability?.
It is clear that both options have their advantages, but we must know that  repeatibility is of great importance to qualify and quantify. But when it comes to detect traces of this band (the presence of talc) an increase in resolution will help us.
This band allows us to calculate the signal to noise ratio of the instrument.

9 ene. 2012

Poliestireno / Polyestyrene Standards

Polyestyrene is one of the most common filters to calibrate MIR ( Middle Infrared Spectrophotometers). It is really helpful to check the resolution of the instrument and the position of the peaks.
NPL can supply polystyrene filters calibrated for the MIR region.
Combination bands and overtones from the MIR region, appear in the NIR (Near Infrared), anyway the absorptivity of these bands decrease in this region, that is the reason it does not have the correct features to cover the entire NIR range.
Poliestireno es uno de los filtros más comunes para calibrar los equipos de Infrarrojo Medio (MIR). Es una ayuda importante para comprobar la posición de los picos de absorción y la resolución del equipo.
Organismos como el NPL, suministran filtros calibrados para hacer estas comprobaciones en la region MIR.
En la región NIR aparecen las bandas de combinación y los sobretonos de la región MIR, pero estas bandas son de menor intensidad a medida que disminuye la longitud de onda. Esto hace que las bandas del poliestireno en cierta zona de la región NIR, no sean de gran utilidad. No obstante es el filtro que los fabricantes de equipos NIR adoptan para sus productos normalmente

Polyestirene Spectrum in the NIR range (1100-2500 nm)

Polyestyrene has very sharp bands and their peaks positions depend of the spectral resolution of the instrument.
Anyway NIR manufacturers use this filter internally on the instruments to check the wavelength scale.
Accuracy and precision are checked and a report generated.
El poliestireno tiene bandas de absorción muy marcadas y la posición de los picos depende de la resolución del instrumento. Los diagnósticos que usan este filtro hacen una comprobación de la precisión y la longitud de onda generando un informe. 

Polyestyrene is also used to check the instrument bandwidth.
Con el filtro de poliestireno también calculamos el ancho de banda del instrumento

6 ene. 2012

Estándares para "Longitud de onda" en Reflectancia

Uno de los estándares mas usados para verificar los equipos NIR en la escala de longitud de onda es el SRM 1920. Es una mezcla de óxidos de tierras raras (dysprosium oxide, herbium oxide and holmiun oxide), mezcladas y encapsuladas  en ubna cubeta con ventana de zafiro. Este estándar los distribuía el NIST, pero ya no está disponible a través de este organismo. Sin embargo siguen fabricando estándares  con las mismas características y con algunas variantes (como puede ser la adición de talco).
La posición de las bandas de absorción puede variar ligeramente en función de la resolución de los equipos, por lo que el NIST fabricó otro standard de similares características (el SRM 2036) de mas sencilla producción, y que elimina el efecto de variación de la posición de las bandas. El SRM 2036, tiene la misma composición que el SRM 1920, pero lleva una pieza de polytetrafluoretileno (PTFE) en contacto con los tres óxidos de tierras raras.

De la página Web del NIST:
SRM 2036, "Near-Infrared Wavelength/Wavenumber Reflection Standard." This Standard Reference Material (SRM) is a certified transfer standard intended for the verification and calibration of the wavelength/wavenumber scale Near-Infrared (NIR) spectrometers operating in diffuse reflectance mode. SRM 2036 is a combination of a glass that is compositionally identical to SRM 2065 Ultraviolet-Visible-Near–Infrared Transmission Wavelength/Wavenumber Standard physically contacted with a piece of sintered polytetrafluoroethylene (PTFE). The combination of rare earth oxide glass with a nearly ideal diffuse reflector provides reflection-absorption bands that range from 15 % R to 40 % R. SRM 2036 is certified for the 10 % band fraction centroid of seven bands spanning the spectral region from 975 nm to 1946 nm (air wavelength). In addition, it is certified for the 10 % band fraction centroid location of the same seven bands in the spectral region from 10 300 cm-1 to 5 130 cm-1 at 8 cm-1 resolution (vacuum wavenumber). The optical filter is 25 mm in diameter and 1.5 mm thick. The sintered PTFE is 25 mm in diameter and approximately 6 mm thick. A unit of SRM 2036 consists of the optical filter-PTFE assembly mounted in an optical holder, contained in a wooden box.

Que nos aportan estos filtros al verificar nuestro equipo NIR:
Es importante por una parte controlar la exactitud de la longitud de onda de nuestro equipo respecto a un estándar con trazabilidad NIST.
Por otro lado es importante el control de la precisión del equipo, en lo que a la posición de las bandas de longitud de onda se refiere.
Un informe sobre la verificación de longitud de onda sería:

El filtro con el que se realizó esta verificación (con trazabilidad NIST) es una variante del SRM 1920 original, por lo que incluye las longitudes de onda nominales de 1261, 1681 y 1935 nm.
Dependiendo de la composición de los filtros, se puede extender el rango de longitud de onda.

Debate sobre estándares de longitud de onda en  NIRS Forum

3 ene. 2012

Estándares para "respuesta fotométrica".

Un espectro NIR (infrarrojo cercano), lo vemos en un gráfico de dos dimensiones, en el "eje X" están los valores de longitudes de onda (expresados en "nm" ó en "cm-1) y en el "eje Y" la respuesta fotométrica (expresada en "log 1/R").

Problemas ópticos electrónicos, mecánicos, desajustes, pueden ser causas de que la respuesta fotométrica , o la exactitud de la longitud de onda no sean las adecuadas y no estemos trabajando de una manera correcta.
Los equipos llevan normalmente unos filtros en su interior para pasar una serie de diagnósticos de modo que nos adviertan de si estamos fuera de especificaciones en lo que a longitud de onda se refiere (holmio, didimio, poliestireno,...).
En lo que se refiere a los tests de respuesta fotométrica, se realizan con una cerámica que refleja aproximadamente un 80% de la radiación incidente (la misma cerámica que se utiliza para hacer el blanco cuando trabajamos en reflectancia).Con esta cerámica se mira si los niveles de ruido están dentro de especificaciones).
Para un mayor control del equipo(en lo que a respuesta fotométrica se refiere) respecto a muestras que reflejen un porcentaje menor (como en el caso de la mayoría de las muestras de piensos y materias primas), que puede ser del 40, 20, 10 ó 2%. Con ello comprobamos si la respuesta del detector es lineal.
También en ocasiones nuestras muestras tienen una alta reflectancia, y para ello existen muestras de control del 99%.
Es por tanto conveniente comprobar que los equipos responden correctamente respecto a muestras de estos porcentajes, pero aparte estas muestras deben de ser duraderas en el tiempo y a se posible certificadas.
Afortunadamente en el mercado existen estas muestras, y los propios fabricantes de los equipos NIR, pueden ofrecernos un servicio de mantenimiento para comprobar (con estas muestras) que nuesto equipo esta dentro de especificaciones.
Uno de los materiales usados para este tipo de muestras es el "espectralon". Este tipo de muestras muestra lo que se denomina mayor "lambertian reflectance", lo que la hace muy adecuada para los equipos NIR.
Los estándares deberán de tener trazabilidad con Institutos acreditados como puede ser el NIST.

1 ene. 2012

NIPALS: Principal Components Analysis with "R" (Part: 002)

We started some posts based on the tutorials of:
"Multivariate Statistical Analysis using the R package chemometrics"
The first post was:
Now we continue with a second part.
The graphics help us to decide the number of PCs, but for the tutorial we decided 5 PCs.
So, let´s calculate the PC space:
> X.pca<-princomp(X)
The  function pcaDiagplot gave to us an interesting plot which help to us to detect outliers, let´s apply this function in R:
> res<-pcaDiagplot(X,X.pca,a=5)
We get this plot:
In this  plots we see two distances: orthogonal and score distances.
Orthogonal distance: Distance between the object (in the original space) and its orthogonal projection on the PCA subspace.
Score distance: Distance of and object projected on the PCA space to the center.

Some chemometric software has the NIPALS Algorithm included  in order to reduce all our original X matrix to a few principal components.
NIPALS Algorithm (nonlinear iterative partial least square algorithm) was developed by H. Wold (1966).
The idea is to substract the reconstruction matrix by the first PC1 to the original matrix (X) getting a residual matrix (E1). From this "E" matrix, we calculate the second principal component PC2.
We have a new reconstruction matrix (the sum of PC1 and PC2) and we substract it again from X, getting a smaller residual matrix (E2), and we continue again with more PCs untill the desired number of PCs or untill "E" becomes very small.
A graphics plot of the variance explained versus number of PCs will help us to decide the cuttoff.
In Principal Components Analysis with "R" (Part: 001), we decided looking at this plot 5 PCs. So lets apply in R this number of components to the NIPALS Algorithm.

> X_nipals<-nipals(X,a=5)
We get some warnings like:
WARNING! Iteration stop in h= 2  without convergence!
In the NIPALS Algorithm, there is one more argument called iteractions (stepwise calculation), that in the case of  "nipals(X,a=5)" lives the default value (it=10), and the tolerance limit too (tol=0,0001).
Let´s try with:
> X_nipals<-nipals(X,a=5,it=160)
No warnings in this case.
> X_nipals<-list(scores=X_nipals$T,loadings=X_nipals$P,sdev=apply(X_nipals$T,2,sd))
> res<-pcaDiagplot(X,X.pca=X_nipals,a=5)
We get this plot:

Graphics, for:
> res<-pcaDiagplot(X,X.pca,a=5)
are almost the same and I not notice any diference.

We will continue soon.