GLOBAL KNOWLEDGE ARK

Chemistry · Lesson

Chemometrics, multivariate signals and validation

Use transparent multivariate calculations to distinguish information, fitted residuals, represented variance and held-out prediction errors. Preserve units and the boundary between model building and independent validation.

Back to the Chemistry map

By the end, you can

  • Fit a small overdetermined response model and interpret its residuals.
  • Calculate a centered principal-component model and explain the effect of scaling.
  • Compare mean error, absolute error and prediction root-mean-square error.
  • Keep learned preprocessing inside the training boundary.
01

Many signals do not automatically supply many independent chemical facts

Chemometrics applies mathematical and statistical methods to chemical observations. A spectrum can contain many channels, and a set of instruments can produce complementary signals. Before fitting a model, define what each coordinate represents, its units and any transformation, and how rows relate to sampling units.

A channel may contain useful analyte information, background, drift, noise or an interferent response. Highly related channels can share the same information. A model coefficient, score or prediction should be connected to a chemical quantity through calibration and independent evidence, not assigned a chemical identity merely because a numerical fit exists.

The following tiny datasets are invented to make the arithmetic and information limits visible. They contain no measured spectra, trained production model or demonstrated real-world accuracy.

02

A least-squares solution can expose an inconsistent response

Use a stipulated linear model y=Mx with dimensionless matrix rows (1,0), (0,1) and (1,1). The two coefficients x₁ and x₂ are response components in U, rather than validated analyte amounts. Give response vector y=(2.10, 2.90, 5.10) U. The third observation would equal the sum of the first two if all three lay exactly on this model.

An equal-weight least-squares fit minimizes the sum of squared residuals. With full column rank, its normal equations are (MᵀM)x=Mᵀy, where Mᵀ denotes the transpose. Here MᵀM has rows (2,1) and (1,2), while Mᵀy=(7.20,8.00) U. Solving gives x₁=2.133333 and x₂=2.933333 U.

Fitted responses are 2.133333, 2.933333 and 5.066667 U. Define residual as observed minus fitted; residuals are −0.0333333, −0.0333333 and +0.0333333 U. Sum of squared residuals is 0.00333333 U². The two normal-equation residual projections vanish, as required by this fit.

Small residuals show agreement with the chosen model and fitting criterion; they do not establish unique chemical identity, valid coefficients outside the calibration range or equal actual measurement uncertainties. If coefficient columns become proportional, a nonzero null direction can preserve predictions while changing coefficients. A low residual cannot restore lost independent information.

03

PCA finds represented variance in a chosen coordinate system

Principal component analysis, abbreviated PCA, identifies orthogonal directions of variance in centered data. Feature scaling changes the coordinate system and can change those directions. Centering subtracts a learned mean; it is different from dividing features by a scale. A software routine that centers data need not automatically standardize feature variances.

Give three invented observations with two features in a shared response-unit convention U: (1,2), (2,4) and (3,6). Column mean is (2,4), and centered rows are (−1,−2), (0,0) and (1,2). Using sample covariance denominator n−1=2 gives covariance matrix with rows (1,2) and (2,4) in U².

Its eigenvalues are 5 and 0 U². One normalized first axis is (1/√5,2/√5), with scores −√5, 0 and +√5 U. The second feature is exactly twice the first in this invented dataset, so one component reconstructs all centered coordinates and represents 100% of this dataset’s variance. The sign of an axis is arbitrary; reversing it reverses scores while preserving reconstruction.

Divide the second feature by two before centering. The new covariance has rows (1,1) and (1,1), eigenvalues 2 and 0 U², and first axis (1/√2,1/√2). The underlying three observations still have a perfect linear relation, but their numerical axis changes with scaling. If features have different physical units, the scaling and resulting interpretation need especially explicit justification.

Represented variance is not chemical identity, causal importance, class discrimination or performance on new material. Large variance can come from irrelevant effects. A PCA score plot can help explore observations, but its interpretation and applicability require evidence beyond the variance calculation.

A transparent three-observation PCA example
ObservationFeature 1 / UFeature 2 / UCentered pair / UFirst score / U
11.002.00(−1, −2)−2.236068
22.004.00(0, 0)0
33.006.00(1, 2)+2.236068

Invented two-feature observations in a shared U unit convention. Means (2,4) are subtracted; covariance uses n−1=2. First axis is (1/√5,2/√5), and scores are projections onto it. All centered observations lie on that one line. The displayed scores are rounded; the formulas in the lesson retain exact √5 values. No measured spectra, chemical class or predictive performance is represented.

04

Opposite errors can cancel an average bias

Define held-out prediction error as prediction minus the supplied reference. For four hypothetical independent units, give references 1.20, 1.80, 3.40 and 3.60 mg L⁻¹ and predictions 1.00, 2.00, 3.00 and 4.00 mg L⁻¹. Errors are −0.200, +0.200, −0.400 and +0.400 mg L⁻¹.

Mean error, used here as the signed average bias descriptor, is zero. Mean absolute error MAE is (0.2+0.2+0.4+0.4)/4=0.300 mg L⁻¹. Root-mean-square error of prediction RMSEP is √[(0.04+0.04+0.16+0.16)/4]=0.31622777 mg L⁻¹. Zero mean error therefore does not imply every prediction is correct.

These descriptors use the denominator four because they summarize the supplied four prediction errors. They are not an estimate of a confidence interval or a complete measurement uncertainty from this tiny invented set. Reference uncertainty, sampling design and the intended matrix and concentration domain would matter in a real evaluation.

If every supplied reference is increased by 0.500 mg L⁻¹ while predictions stay fixed, all errors shift by −0.500. Mean error becomes −0.500 mg L⁻¹ and mean squared error becomes 0.100+0.250=0.350 (mg L⁻¹)², giving RMSEP=0.59160798 mg L⁻¹. The distinction between systematic shift and dispersed errors is visible without treating either dataset as real validation.

05

Learn transformations using training information only

Suppose training feature values are 1.00 and 3.00 U from units U1 and U2, while held-out values are 9.00 and 11.0 U from new units U3 and U4. Training mean is 2.00 U. A centering transformation learned on training gives held-out centered values 7.00 and 9.00 U.

Using all four values to learn the mean gives global mean 6.00 U and held-out centered values 3.00 and 5.00 U. This includes held-out information in model preparation. Even if the unit IDs are disjoint, preprocessing learned from the test side crosses the validation boundary.

Replacing held-out values with 99.0 and 101 U should leave the training mean at 2.00 U. Correct held-out transformed values become 97.0 and 99.0 U, while a leaky global mean would become 51.0 U. This is an algebraic information-leakage illustration, not an invented performance score.

Keep all relevant replicates of one unit together when the question concerns new units, and fit learned scaling, feature selection and tuning within the corresponding training boundary. Group separation alone cannot rule out shared batches, time dependence or an out-of-domain deployment. Validation must reflect the intended use.

06

Connect the model’s success criterion to the chemical decision

A useful multivariate result states its input signals, transformations, fitting criterion, calibration domain and independent checks. Fitted agreement, variance representation and held-out error are distinct evidence. A model can perform well under one matrix or sampling design and fail under another.

Retain the measured observations and processing history, including decisions about background, excluded rows and feature selection. Quantitative predictions need an appropriate basis and uncertainty; structural or mechanistic claims need complementary evidence. An attractive score plot, low training residual or zero mean error cannot supply those requirements by itself.

Instrumental analysis becomes reliable when signal formation, calibration, independent information and validation align with the intended chemical quantity. This chapter’s original examples show those relations under stated assumptions while preserving the limits of each inference.

Worked examples

Fit the three responses to two response components

Use M rows (1,0), (0,1), (1,1) and y=(2.10,2.90,5.10) U.

  1. Normal-equation rows are (2,1) and (1,2), with right side (7.20,8.00) U.
  2. Solve for x=(2.133333,2.933333) U.
  3. Residuals observed−fitted are (−0.0333333,−0.0333333,+0.0333333) U; squared sum is 0.00333333 U².

An equal-weight fitting result for a supplied model, not validated analyte amounts.

Calculate the centered rank-one representation

Use rows (1,2), (2,4), (3,6) in the shared unit convention.

  1. Subtract column mean (2,4) to get centered rows (−1,−2), (0,0), (1,2).
  2. Sample covariance is [[1,2],[2,4]] U² with eigenvalues 5 and 0 U².
  3. First axis (1,2)/√5 gives scores −√5, 0, +√5 U and reconstructs all centered rows.

One component captures this stipulated dataset’s variance without proving chemical discrimination.

Compare cancellation with error magnitude

Use held-out errors (−0.200,+0.200,−0.400,+0.400) mg L⁻¹.

  1. Their mean is zero.
  2. Mean absolute error is 0.300 mg L⁻¹.
  3. Root mean squared error is √0.100=0.31622777 mg L⁻¹.

Zero average bias can coexist with nonzero individual prediction errors.

Preserve the training-only transformation

Use training values 1.00/3.00 U and held-out 9.00/11.0 U from disjoint units.

  1. Training mean is 2.00 U.
  2. Apply it unchanged to test values: centered values 7.00/9.00 U.
  3. Using the global mean 6.00 U instead would incorporate held-out information.

The transformation’s learning boundary matters even when sampling units differ.

Try it yourself

  1. If the two response-model columns become proportional, can a small residual establish unique values of both coefficients?

    Show the answer and reasoning

    No.

    A nonzero null direction can change coefficients without changing fitted responses. Rank and independent information are separate from residual size.

  2. Divide feature 2 by two before PCA in the three-row example. Give the sample covariance and one first axis.

    Show the answer and reasoning

    Covariance [[1,1],[1,1]] U²; first axis (1,1)/√2, with eigenvalues 2 and 0 U².

    The centered coordinates become (−1,−1), (0,0), (1,1). Recalculating their products changes the numerical axis.

  3. Increase every held-out reference by 0.500 mg L⁻¹ while predictions stay fixed. Find mean error and RMSEP.

    Show the answer and reasoning

    Mean error −0.500 mg L⁻¹; RMSEP 0.59160798 mg L⁻¹.

    The original zero-mean error component has mean square 0.100; the common shift adds 0.250, giving total mean square 0.350.

  4. Change held-out feature values to 99.0 and 101 U, keeping training values 1.00 and 3.00 U. Should the learned training mean change? Give correct centered test values.

    Show the answer and reasoning

    No; training mean stays 2.00 U and centered test values are 97.0 and 99.0 U.

    The held-out observations should not alter a transformation learned from training. A global mean of 51.0 U would reveal leakage.

What to carry forward

  • Define signals, units, transformations and sampling units.
  • A fitted residual is distinct from independent information and chemical identification.
  • PCA depends on centering and scaling and describes represented variance.
  • Report error magnitude as well as signed average error.
  • Keep preprocessing and tuning within the training boundary.

References

Teaching resources and reference material supporting this lesson’s explanations and examples.

  1. Analytical Chemistry 2.1: 10.2 Spectroscopy Based on AbsorptionDavid T. Harvey, DePauw University USASourcechem.libretexts.orgRead source
  2. NIST/SEMATECH e-Handbook: How can I tell if a model fits my data?NIST/SEMATECH e-Handbook authors; individual page byline not givenSourceitl.nist.govRead source
  3. scikit-learn developers3 sources
    1. Principal component analysisscikit-learn developersSourcescikit-learn.orgRead source
    2. Common pitfalls and recommended practicesscikit-learn developersSourcescikit-learn.orgRead source
    3. Cross-validation: evaluating estimator performancescikit-learn developersSourcescikit-learn.orgRead source
  4. The Fitness for Purpose of Analytical MethodsH. Cantwell, editor; Eurachem Method Validation Working GroupSource · PDFeurachem.orgRead source