
The one idea
A spectrum can support several different questions. The question determines the model and the evidence it needs.
Principal component analysis (PCA) helps explore what varies. Class modeling can help assess whether a sample fits an established material class. Partial least squares (PLS) regression can predict a numerical property from measurements linked to reference results. These approaches can use the same spectral data, but their outputs are not interchangeable.
Reading 2 set out the development workflow. Here we look inside three tools, using incoming-material identity and granule water content as the pharmaceutical examples. The treatment is introductory; Week 12 takes the methods further, including curve resolution and batch monitoring, and implementation needs more detailed study still [1–3].
Start with the spectrum, not the algorithm
Imagine scanning authenticated lots of lactose monohydrate, mannitol and microcrystalline cellulose by near-infrared (NIR) spectroscopy. Each spectrum contains responses at many wavelengths. Broad, overlapping features make it difficult to find a single wavelength that resolves every relevant difference.
Measurements at neighboring wavelengths often move together. Meanwhile moisture, particle size, temperature, solid form and sample presentation can change the spectrum. Some changes reflect chemical identity; others reflect physical differences within the same acceptable material [2].
Arrange the measurements in a matrix, X:
| Matrix element | Meaning in this example |
|---|---|
| One row | One sample measurement |
| One column | Response at one wavelength |
| Metadata alongside X | Material identity, lot, supplier, moisture, instrument and other context |
Preprocessing changes the geometry of this matrix. Centering, scaling, derivatives and scatter corrections are scientific and modeling choices. Applied automatically, they can remove useful information or emphasize noise. Development has to establish that they suit the measurement.
PCA: find directions of variation
PCA constructs new axes from weighted combinations of the original variables. The first principal component captures the greatest available variance in the preprocessed X data. The second captures the greatest remaining variance while staying orthogonal to the first. Further components continue the pattern.
PCA is unsupervised: material labels and reference moisture values do not define the axes. Colouring a plot by identity afterward does not change how the components were calculated.
Think of a cloud of points viewed from different angles. PCA finds the directions along which the cloud spreads most. It gives a compact representation when much of the variation lies in relatively few directions.
But the widest direction need not be the most useful one. If particle-size effects dominate the spectra, the first component may reflect them more strongly than identity or water content.
Scores locate samples; loadings describe the axes
Three terms make PCA plots much easier to read:
| Term | What it describes | Question it helps answer |
|---|---|---|
| Score | A sample’s coordinate on a component | Where does this sample sit relative to other samples? |
| Loading | A variable’s contribution to a component direction | Which measured variables contribute to that pattern? |
| Residual | Variation left outside the retained component model | What does the reduced representation fail to describe? |
In a score plot, nearby points have similar retained scores. That does not guarantee their full spectra are similar: they can differ in omitted components or residual structure.
In a loading plot, a large loading magnitude means a strong contribution to that component under the chosen preprocessing. It does not by itself prove a molecular assignment or a causal mechanism. Interpret it with spectroscopy, materials knowledge and supporting experiments.
The sign of a component is arbitrary: reversing both its scores and its loadings describes the same model. A sample on the positive side of PC1 is not inherently better, purer or wetter.
A calculated example: rotate the view

Download the synthetic example data.
The left panel shows two correlated instrument responses. The right panel shows the same observations after centering and rotation onto principal components. The long direction becomes PC1, carrying 96.9% of the variance; the short perpendicular direction becomes PC2, carrying 3.1%.
Nothing about the samples changed. Only the coordinates used to describe their measurements did.
A spectrum works the same way in many dimensions. Keeping only a few components gives a reduced representation. The explained-variance percentage says how much variation in the preprocessed X data is kept; it is not an identity-test accuracy or a concentration-prediction accuracy.
Pharmaceutical case: three excipients on a score plot
Suppose a development PCA plot shows three groups. Coloured by reference identity, one group is lactose, one mannitol and one cellulose.
That is encouraging exploratory evidence. Now ask:
- Were the labels established independently?
- Does each group span multiple lots and relevant suppliers?
- Were the materials measured under comparable conditions?
- Could acquisition day, instrument, moisture or particle size explain the grouping?
- Does a third component reveal differences hidden by the first two?
A useful follow-up experiment deliberately varies the likely confounders. For example, measure relevant particle-size grades of each material under controlled conditions. If the apparent identity grouping collapses, the original model was leaning on physical differences that happened to come with the development set.
PCA helps formulate this investigation. It does not replace it.
From exploration to an identity decision
An operational identity procedure needs more than coloured clusters. It needs a defined way to evaluate a new sample and a response to an unacceptable or unsupported result.
Soft independent modeling of class analogy (SIMCA) is one class-modeling approach built on PCA. A separate model describes the variation within each material class. A new spectrum is evaluated for compatibility with a class model using the chosen implementation’s diagnostics and decision limits.
One useful distinction is between distance within the modeled score space and distance from the modeled subspace. A sample may be extreme along a familiar direction, or carry a spectral pattern the retained components describe poorly. Both can matter to class compatibility. Reading 7 names them: Hotelling’s T² and the Q residual.
Unlike a rule that always assigns the nearest label, class modeling can let a sample fit no class or more than one. Ambiguity needs a defined operational response. These outcomes depend on how the model was built and on its thresholds; they are not guarantees of any particular software.
| Challenge sample | What the identity procedure should establish |
|---|---|
| Independent authentic lactose lot | Can expected target variation be accepted? |
| Relevant non-target excipient | Can the procedure reject a plausible alternative? |
| Authentic lactose from a new supplier | Does the supported domain cover this variation? |
| Mixture or adulterated sample | What can be detected, and at what level, if this is part of the intended purpose? |
Performance has to be demonstrated with independent samples and relevant challenges. Accepting a spectrum as lactose does not establish freedom from low-level contamination [2, 3].
PLS: connect spectra to a reference quantity
Now return to the drying granules. The question is numerical: what is the water content?
Pair each spectrum with a suitable reference result, such as matched Karl Fischer water content. X holds the spectral measurements; Y holds the reference water values.
PLS regression builds components from the relationship between X and Y. Where PCA follows X variance alone, PLS uses the outcome to seek components that are useful for modeling that relationship. That makes PLS supervised.
It does not make PLS immune to confounding. If wetter samples also happen to be hotter, a model can exploit temperature-associated spectral changes, then fail when temperature and moisture vary independently.
Use the workflow from reading 2: representative matched samples, batch-aware splitting, preprocessing inside resampling, tuned complexity and a final independent assessment. Judge prediction error and bias where the drying decision is made, rather than assuming that a strong fit or a large explained-variance percentage establishes suitability.
One measurement, three different outputs
| Approach | Information used to develop it | Typical output | Evidence needed for the proposed use |
|---|---|---|---|
| PCA exploration | X; labels can inform interpretation afterward | Scores, loadings, explained variance and residuals | Stability of patterns, measurement understanding and investigation of confounding |
| Material class model | X and authenticated membership information | Compatibility with a defined class | Independent target lots, non-target challenges and justified decision rules |
| PLS regression | X paired with a numerical reference Y | Predicted quantity | Independent error and bias assessment, reference-method support and applicability controls |
PCA can also sit inside a predictive pipeline, as in principal component regression (PCR). That is a further modeling choice; a PCA score plot alone does not perform regression or establish identity.
Where the analyst sits
The analyst translates geometry into chemical questions. If samples move on a score plot, what changed? If a lot fails a class model, is it the wrong material, or acceptable variation outside the calibration’s experience? If a moisture prediction looks plausible, is the spectrum inside the supported domain?
The tools make patterns visible and predictions possible. Pharmaceutical judgment establishes what those outputs mean for the material and the decision.
For discussion
- PC1 explains most of the variance. Why might it still be a poor predictor of water content?
- Two samples overlap in a PC1–PC2 plot. What differences could remain hidden?
- Why does colouring a PCA plot by material name not make the PCA calculation supervised?
- A sample fits two material class models. What should the procedure specify before such a sample arrives?
- Design a development experiment that separates moisture effects from temperature effects in an NIR calibration.
Bridge back to the week
Next: Where the Measurement Lives, which asks where these spectra come from and which material they describe. Return to Week 11.
Data and sources
Synthetic PCA data: the 40 two-variable observations behind the rotation figure, with their PC1 and PC2 scores; PCA summary: explained variance and loadings; reproduction script and requirements. Figure: 3840 × 2160 pixels, computed with a fixed seed.
[1] M. Kuhn and K. Johnson, Applied Predictive Modeling (Springer, 2013). Chapter 3 for preprocessing and dimensionality reduction, Chapter 4 for evaluation and tuning, Chapter 6 for regression approaches including PLS and principal component regression. DOI.
[2] US Food and Drug Administration (FDA), Development and Submission of Near Infrared Analytical Procedures (guidance, 2021). Qualitative and quantitative NIR model development and use. Read its historical Q2 references alongside current Q2(R2) and Q14. Guidance.
[3] United States Pharmacopeia (USP) ⟨1039⟩ Chemometrics. Compendial context for multivariate analysis, qualitative and quantitative applications, and lifecycle practice. Licensed compendial text; the public preview describes the scope, and the full chapter may not have been consulted. USP chapter.
[4] International Council for Harmonisation (ICH) Q14 and Q2(R2): development and intended-use validation context. Q14 guidance · Q2(R2) guidance.
The excipient score-plot case is a constructed teaching example; the rotation data are synthetic.