NIR Calibration and Chemometrics
A practical guide to NIR calibration and chemometrics: building PLS models, choosing preprocessing, validating with independent samples, and maintaining them.
Key numbers
Illustrative spectrum for teaching, not measured data.
Scan the sample to light up the bands, then pick a constituent.
Quick check
Matching lesson: L23Why Calibration is the Core of NIR Performance
An NIR instrument without a good calibration is just an expensive light source. The hardware measures absorption spectra — thousands of data points across hundreds of wavelengths. The calibration model transforms those data points into predicted protein, moisture, fat, or whatever parameter you need.
Calibration quality depends on three things: the quality of reference data used to build it, the diversity of samples in the calibration set, and the appropriateness of the mathematical model. Errors in any of these translate directly into prediction errors in production.
This is why NIR accuracy is often limited not by the instrument, but by the reference laboratory. If your Kjeldahl values have a standard deviation of ±0.3% protein, your NIR calibration cannot outperform that — no matter how expensive the instrument.
Reading the Charts: What Calibration Software Actually Shows You
Every chemometrics package (Camo Unscrambler, Bruker OPUS QUANT, Foss WinISI, Thermo TQ Analyst, ProSpect) outputs the same four diagnostic charts. Knowing what each chart actually tells you is the difference between trusting a model and shipping a bad one. The data below is illustrative — synthetic but matched to real-world ranges for grain protein.
1. Predicted vs Reference Scatter
The single most-used calibration plot. Reference value (X) plotted against NIR prediction (Y). Points should hug the red 1:1 line; the cyan line is the actual regression fit. Tight band = good calibration. Wide spread = high SEP. A regression line that diverges from the 1:1 means there's slope or bias bias drift.
2. RMSECV vs PLS Factors (Elbow Plot)
Adding more PLS factors always reduces calibration error (RMSEC), but the cross-validation error (RMSECV) hits a minimum and then climbs as the model overfits to noise. Pick the factor count just at or before the elbow. The orange RMSEP line on a held-out test set should track close to RMSECV — if RMSEP > RMSECV by a lot, the calibration is overfit.
Optimal: 6 factors. Past that, RMSEP diverges — the model is learning noise.
3. Residual Plot (Predicted − Reference)
Each bar is one sample's prediction error. A healthy calibration shows residuals randomly distributed around zero, with most bars inside the ±threshold band. Bars outside the band are outliers — investigate their reference value (suspect lab error?) before removing them. Systematic positive or negative drift across samples = bias.
Threshold: ±0.4%. Outliers: S08 (lab over-read?), S23 (off-spec sample).
4. Calibration Drift / Bias Over Time
Reference vs NIR run in parallel on production samples over weeks. The cyan line is reference, the orange line is NIR prediction. A persistent gap = bias drift. A widening gap = calibration losing its connection to the matrix. This chart is what tells you when to apply a slope/bias correction or commission a full calibration update.
Drift detected: NIR reading is +0.18% bias on average — apply slope/bias adjustment, or schedule a 30-sample calibration update.
How experienced calibration developers read these together
- • Scatter plot wide? Either reference data is noisy, or your spectral preprocessing isn't separating signal from baseline drift.
- • Factor curve climbing fast after the elbow? You don't have enough independent samples — the model is being forced to overfit.
- • Residual plot showing systematic shape (e.g. all positives at high values)? You have a non-linearity the PLS isn't capturing — try adding a derivative preprocess or splitting the calibration range.
- • Drift chart trending one direction? Time to call a calibration update meeting — slope/bias is no longer enough.
How PLS Regression Works in NIR
Partial Least Squares (PLS) regression is the dominant chemometric method for NIR calibration. It solves a fundamental problem: NIR spectra have hundreds or thousands of variables (wavelengths), but you typically have far fewer samples. Classical multiple regression falls apart in this situation.
PLS works by extracting a small number of latent variables (factors) from the spectral data that explain the most variance in both the spectra and the reference values simultaneously. Each additional factor explains more of the remaining variance. The challenge is choosing how many factors to use — too few and the model underfits; too many and it overfits to noise.
Key PLS Metrics
- RMSECV — Root Mean Square Error of Cross-Validation. Estimates model performance on new samples.
- RMSEP — Root Mean Square Error of Prediction. Actual error on a held-out test set.
- R² — Coefficient of determination. How much variance the model explains.
- RPD — Ratio of Performance to Deviation. Values above 3 indicate a useful calibration.
Preprocessing Methods
- SNV (Standard Normal Variate) — removes scatter effects from particle size variation.
- MSC (Multiplicative Scatter Correction) — similar to SNV, applied relative to a reference spectrum.
- Savitzky-Golay derivatives — enhances spectral features and removes baseline drift.
- Mean centering — shifts data so the model focuses on variation, not absolute values.
Calibration Validation: How to Know Your Model Works
A calibration that looks good on the development set can fail completely on production samples. Overfitting is the most common cause — the model has learned the noise in the calibration data rather than the true signal.
Cross-Validation
Split the calibration set into groups. Build the model on all but one group, predict that group, rotate through all groups. RMSECV estimates how the model will perform on unseen data without requiring a separate test set.
Independent Validation Set
Hold back 20–30% of samples from calibration development. Use this set only once, after the model is finalized. RMSEP from a true independent set is the gold standard performance estimate.
External Validation Samples
Collect new production samples over weeks or months after calibration development. Run both NIR and reference methods in parallel. This catches calibration drift and sample population drift that internal validation misses.
Reference Methods: The Y in Your PLS Model
PLS regression learns to predict reference values (Y) from NIR spectra (X). The quality of those Y values is the silent ceiling on every calibration you'll ever build. This section covers which reference methods are typically used, how their reproducibility limits NIR accuracy, and how to handle reference data variability when building a calibration set.
Reference reproducibility figures are typical published inter-laboratory values from ISO/AOAC ring trials. Method codes link to the issuing organization's official catalog (paywalled per-method documents). For the full reference method index with ISO/AOAC/AOCS/AACC/EBC/ASBC links, see the NIR Laboratory Guide.
Reference data quality > calibration math
A bigger PLS factor count, a fancier preprocessing chain, and a more aggressive outlier removal will not push NIR accuracy below the reference noise floor. Most calibration projects stall because the reference data has noise the calibration developer hasn't accounted for — duplicate samples assayed by two technicians; method drift over the months it took to collect samples; mixed reference methods (Kjeldahl + Dumas) treated as one.
Sample selection — match reference protocol
Every reference method has its own sampling and prep procedure (e.g. Soxhlet on a 5 g defatted residue, Kjeldahl on a 1 g digested aliquot, oven drying on a thin even layer). The sample you scan with NIR must be representative of what the reference method actually saw — same lot, same homogenization. Otherwise the calibration learns the difference between sampling protocols, not chemistry.
Pre-clean reference data before fitting
Run duplicates on a subset of calibration samples and look at reference reproducibility before you build the model. If two replicates of the same sample disagree by more than 2× the reference reproducibility, drop both. Sort samples by reference value and look for visible trend breaks — those often signal a method change mid-collection.
Maintaining the reference link over time
- • Slope & bias adjustment — when SEP drifts but reference and NIR are still linearly related, a 2-parameter linear correction restores agreement without rebuilding the model.
- • Calibration update — when slope/bias no longer fits, add ~30–50 new representative samples (with current reference values) and rebuild.
- • Calibration transfer (Piecewise Direct Standardization) — when moving a calibration to a new instrument, scan a 10–20 sample transfer set on both instruments and apply PDS or DS correction.
- • Reference method change — switching from Kjeldahl to Dumas, or from Soxhlet to acid hydrolysis, requires recalibration. Don't apply slope/bias to bridge two different chemistries.
Go deeper in the course
Enroll — $99 lifetime 14-day refund
Read more on the blog
- How to Transfer NIR Calibration Between Instruments Effectively
- PLS Regression for NIR: Step-by-Step Guide for Food and Feed Calibration
- Why Does R² Lie? Understanding RPD, SEP, and RMSEP in NIR Accuracy
Links open the current site. Posts move here later.
Related
Questions
How to choose the right number of PLS factors for an NIR model?
Selecting the optimal number of PLS factors, or latent variables, is a balance between capturing constituent-related variation and avoiding overfitting by modeling noise. Monitor the Root Mean Square Error of Cross-Validation (RMSECV); it should decrease to a minimum and then plateau or increase. The point just before it increases is often optimal. Including too many factors will make the model perform poorly on new samples, even if calibration statistics look good.
What is a good RPD and RMSEP for an NIR calibration?
The Root Mean Square Error of Prediction (RMSEP) should be close to the lab reference method's reproducibility. The Ratio of Performance to Deviation (RPD) provides context by relating the SEP (Standard Error of Prediction) to the standard deviation of the reference data. An RPD above 3 is generally considered acceptable for quality control, while an RPD over 5 indicates a good calibration for most food and feed applications.
When to use SNV vs MSC for NIR scatter correction?
Standard Normal Variate (SNV) and Multiplicative Scatter Correction (MSC) both correct for baseline shifts and scaling effects caused by particle size and pathlength differences. SNV works on each spectrum individually, making it robust if outliers are present in the calibration set. MSC uses a mean spectrum as a reference, which can be advantageous for relating all spectra to a common standard, but this reference can be skewed by outliers.
How to transfer an NIR calibration to a new instrument?
Directly copying a calibration model to a new instrument often fails due to minor optical differences. To transfer a model, measure a standardized set of 10-20 diverse samples on both the original ('master') and new ('slave') instruments. Use software to apply a mathematical correction, such as Piecewise Direct Standardization (PDS) or a simple slope/bias adjustment, to align the new instrument's predictions with the master instrument's results.
How to select samples for a robust NIR calibration?
A robust calibration requires samples that represent all sources of variability the model will encounter during routine use. This includes variation in raw materials, processing conditions, seasonality, and storage. Start with at least 50-100 samples covering the full constituent range. Use spectral selection algorithms, like Kennard-Stone, to ensure the selected samples are representative of the spectral and chemical diversity of the total population.
How often to update NIR calibrations with slope/bias adjustments?
After initial validation, monitor model performance by regularly checking a few samples against the reference method. A simple slope and bias adjustment is often sufficient for routine maintenance. If the Standard Error of Prediction (SEP) increases significantly or a consistent bias appears that is not due to reference method drift, a more comprehensive model update with new samples may be required. Annual re-validation is a common practice.