What a PLS calibration is, and why every step needs validating
Partial least squares regression relates a spectral matrix X to reference values Y through a small number of latent variables, and it owes its place in near-infrared calibration to its ability to handle many noisy, collinear and even incomplete variables [1]. Geladi and Kowalski's tutorial sets out where ordinary regression fails on such data, develops PLS as the remedy, and gives an algorithm together with practical hints for its use [2]. The method itself is explained in the companion article How NIR Calibration Works: PLS Explained; this guide is about the decisions a practitioner makes while building one. Each of them — how the samples are split, which pre-processing is applied, how many latent variables are kept, which samples are removed — changes the figures of merit, and Westad and Marini show that the level at which a model is validated affects both its reported error and its chosen dimensionality [3].
Splitting the data
Snee's review of regression validation concludes that data splitting, in which one part of the data estimates the model and the remainder measures its prediction accuracy, is an effective way to validate a model when it is not practical to collect new data, and recommends Kennard's DUPLEX algorithm for making the split when there is no obvious variable, such as time, on which to base it [4]. The related Kennard–Stone procedure selects points sequentially so that each step covers the experimental region uniformly [5], which is why it is widely used to pick calibration samples that span the spectral space. A purely random split is not automatically sound: Westad and Marini warn that repeatedly dividing a data set at random into calibration and test sets can only be justified when there is no systematic stratification of the samples, and they distinguish validation levels — repeatability, reproducibility, instrument and raw-material variation — that a split should respect if the error estimate is to say anything about future samples [3].
The size of the hold-out set is also a decision, not a convention. In a Monte Carlo study on NIR spectra of whole maize plants, Martens and Dardenne drew small calibration sets of 40 to 120 samples from a database of 922 and found that reserving an independent test set from an already small pool reduced predictive performance, while full cross-validation gave better predictions and was only slightly optimistic [6]. The practical reading is that a separate test set is most valuable when samples are plentiful or when it represents a genuinely later or different population; with few samples, cross-validation makes better use of them [3][6].
Choosing the pre-processing
Rinnan et al. group the common NIR pre-processing methods into scatter corrections (MSC, SNV, normalisation) and spectral derivatives, and compare their effects on real data [7]; the mechanics are covered in the MSC/SNV guide and the Savitzky-Golay guide. For the calibration workflow the point is procedural: pre-processing settings are hyper-parameters of the model, so candidate pipelines should be compared on the same validation design as the number of latent variables, never on the calibration fit. Wiklund et al. note that their component-selection test also acts as an indicator that the data require a pre-treatment, which is a useful cross-check when a raw-spectrum model needs many more components than a derivative model [8].
How many latent variables
The number of latent variables is the single most important setting in PLS: too few leave chemical information unmodelled, too many fit noise that will not recur in new samples [1][2]. The standard tool is cross-validation, whose general form Stone introduced for the choice and assessment of predictors [9]; in PLS the model is refitted with parts of the data left out, and the cross-validated error is plotted against the number of components [1]. The conventional rule is to stop at or just before the minimum of that curve, but the choice of segments matters. Shao showed that leave-one-out cross-validation is asymptotically inconsistent for selecting the model with the best predictive ability, and that the inconsistency is corrected by leaving out larger blocks of observations [10]; in practice this favours segmented or grouped cross-validation, with replicate measurements and samples from the same batch kept in the same segment, over leaving out single spectra. Wiklund et al. offer a complementary randomization test that requires no exclusion of data and that, on simulated data of known dimensionality and ten real data sets, worked well in combination with other selection rules [8].
Reading the diagnostics
Three error figures appear in every model report. The calibration error (RMSEC) describes the fit and is always the smallest; the cross-validation error (RMSECV) estimates prediction within the calibration population; the prediction error on an independent set (RMSEP) is the only one that tests samples the model has never seen, and the validation level of that set decides what it means [3]. ISO 12099 lays out the statistics for performance measurement, including the standard error of prediction and the bias, and gives examples of outliers and control charts in its informative annex [11]. A large gap between RMSECV and RMSEP, or a bias on the test set, usually means that the test samples differ systematically from the calibration population rather than that the model is wrong in itself [3].
Sample diagnostics complete the picture. Wold et al. review the standard PLS diagnostics — scores, loadings, residuals and distance to the model — that are used to find samples which lie far from the others in spectral space or are poorly fitted [1]. Hubert and Vanden Branden show that because the common SIMPLS algorithm is built on the empirical cross-covariance matrix and ordinary least squares, its results are affected by abnormal observations; they introduce robust variants with robust RMSECV and RMSEP values, and diagnostic plots that visualise and classify the outliers [12]. Whatever the tool, a sample should be removed from the calibration only with a documented reason: a wrong reference value, a spectrum of a different material, or a measurement fault. Three habits keep the diagnostics honest:
- Decide the validation design first. Fix the split and the cross-validation segments before any pre-processing or component sweep, and use the same design for every candidate so that the comparison is fair [3].
- Report RMSECV and RMSEP together with their validation level. An error estimated on replicate spectra of the same samples is not comparable with one estimated on a later production batch [3].
- Treat outlier removal as a model decision. Record which samples were removed and why; a residual or leverage flag is a prompt to investigate, not a licence to delete [1][12].
Keeping the model alive
A calibration is validated for the population and the instrument state it was built on. ASTM E1655 sets out practices for collecting and treating data for infrared calibrations, describes calibration techniques and criteria for validating model performance, assumes that the analyser operates at the manufacturer's specified conditions at the times of calibration and validation, and provides a questionnaire against which a multivariate calibration can be examined [13]. ISO 12099 adds the operational side: checking instrument stability and a running performance check of the calibration, with control charts as the monitoring tool [11]. Westad and Marini stress that the robustness of a model for predicting future samples matters more than any single figure of merit [3]; in practice this means a routine of reference checks on production samples, control charts of bias and prediction error, and a planned update of the calibration set when new raw materials, seasons or process conditions appear.
The workflow in caliX
The caliX suite organises the steps above as an eight-module workflow for NIR, FTIR and Raman spectra. The Data module imports spectra and reference values from Excel or CSV files and supports data cleaning with PCA and PLS leverage metrics; the pre-processing step offers SNV, MSC, detrending, autoscaling and Savitzky-Golay derivatives [7]; the manual and automatic regression modules build PLS, robust PLS, PCR and regularised models, with the maximum number of latent variables and the number of cross-validation folds set by the user and the automatic mode sweeping pipeline combinations and marking the elbow point of the validation curve [1][10]. Outlier diagnostics include Hotelling T² and Q-residuals, PLS leverage and Mahalanobis distance [12], a Prediction module applies the finished model to unknown samples, and the Data Transfer and Model Converter modules handle instrument standardisation and export of the model for deployment through ProChem. Which split, pre-processing and number of components are right for a given product is established in a feasibility study with your own samples and reference analyses.
References
- [1] Wold, S., Sjöström, M., Eriksson, L. (2001). PLS-regression: a basic tool of chemometrics. Chemometrics and Intelligent Laboratory Systems, 58(2), 109–130. doi:10.1016/S0169-7439(01)00155-1
- [2] Geladi, P., Kowalski, B.R. (1986). Partial least-squares regression: a tutorial. Analytica Chimica Acta, 185, 1–17. doi:10.1016/0003-2670(86)80028-9
- [3] Westad, F., Marini, F. (2015). Validation of chemometric models – A tutorial. Analytica Chimica Acta, 893, 14–24. doi:10.1016/j.aca.2015.06.056
- [4] Snee, R.D. (1977). Validation of Regression Models: Methods and Examples. Technometrics, 19(4), 415–428. doi:10.1080/00401706.1977.10489581
- [5] Kennard, R.W., Stone, L.A. (1969). Computer Aided Design of Experiments. Technometrics, 11(1), 137–148. doi:10.1080/00401706.1969.10490666
- [6] Martens, H.A., Dardenne, P. (1998). Validation and verification of regression in small data sets. Chemometrics and Intelligent Laboratory Systems, 44(1–2), 99–121. doi:10.1016/S0169-7439(98)00167-1
- [7] Rinnan, Å., van den Berg, F., Engelsen, S.B. (2009). Review of the most common pre-processing techniques for near-infrared spectra. TrAC Trends in Analytical Chemistry, 28(10), 1201–1222. doi:10.1016/j.trac.2009.07.007
- [8] Wiklund, S., Nilsson, D., Eriksson, L., Sjöström, M., Wold, S., Faber, K. (2007). A randomization test for PLS component selection. Journal of Chemometrics, 21(10–11), 427–439. doi:10.1002/cem.1086
- [9] Stone, M. (1974). Cross-Validatory Choice and Assessment of Statistical Predictions. Journal of the Royal Statistical Society: Series B (Methodological), 36(2), 111–133. doi:10.1111/j.2517-6161.1974.tb00994.x
- [10] Shao, J. (1993). Linear Model Selection by Cross-Validation. Journal of the American Statistical Association, 88(422), 486–494. doi:10.1080/01621459.1993.10476299
- [11] ISO 12099:2017. Animal feeding stuffs, cereals and milled cereal products — Guidelines for the application of near infrared spectrometry. ISO, Geneva. iso.org/standard/67352.html
- [12] Hubert, M., Vanden Branden, K. (2003). Robust methods for partial least squares regression. Journal of Chemometrics, 17(10), 537–549. doi:10.1002/cem.822
- [13] ASTM E1655-17(2024). Standard Practices for Infrared Multivariate Quantitative Analysis. ASTM International, West Conshohocken, PA. astm.org/e1655-17r24.html