This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

From One Wavelength to a Whole Spectrum

Explore pharmaceutical NIR spectra with PCA, tell scores from loadings, and see how class modeling and PLS turn the same spectra into an identity decision or a water-content prediction, each needing different evidence.
    Graphic titled 'One Spectrum, Three Different Questions'. Three panels. PCA: Explore, with dishes of differently coloured powders beside a spectrometer, asking 'What varies among samples?', with 'Scores describe samples' and 'Loadings describe variables'. Class modeling: Identify, with an analyst inspecting a jar in front of four sample jars, asking 'Does this sample fit the material class?', with 'Defined rules + independent challenges'. PLS: Predict, with a spectrometer beside a titrator and a dish of granules, asking 'How much water is present?', with 'Spectra linked to reference results'. Footer: 'Same measurements. Different objectives. Different evidence. A separated cluster is not a validated identity test.'
    Three uses of the same spectral data: PCA explores variation, class modeling supports identity decisions, and PLS predicts a reference property. Sample colours and instrument scenes are illustrative and do not represent measured excipient properties.

    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 elementMeaning in this example
    One rowOne sample measurement
    One columnResponse at one wavelength
    Metadata alongside XMaterial 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:

    TermWhat it describesQuestion it helps answer
    ScoreA sample’s coordinate on a componentWhere does this sample sit relative to other samples?
    LoadingA variable’s contribution to a component directionWhich measured variables contribute to that pattern?
    ResidualVariation left outside the retained component modelWhat 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

    Figure titled 'PCA changes the coordinates, not the samples', two panels of the same 40 synthetic observations. Left, 'Original measurement coordinates': response B against response A in arbitrary units, the points lying along a rising diagonal from about (−0.5, 1.5) to (3.4, 4.0), with an orange line marking the PC1 direction along the diagonal and a purple line marking the PC2 direction across it. Two highlighted points: A, orange, at the upper right end, and B, purple, at the lower left. Right, 'Same observations in PCA coordinates': PC2 score against PC1 score, the points now spread horizontally from about −2.6 to 2.0 along PC1 (96.9% of variance) and only about ±0.45 along PC2 (3.1% of variance); point A sits at about PC1 = 2.0, PC2 = −0.2, and point B at about PC1 = −2.6, PC2 = 0.45. Both panels are drawn with equal axis scales, so the PC1 and PC2 lines cross at a right angle. Subtitle: 40 synthetic observations, mean-centred, not variance-scaled; percent variance is not predictive accuracy.
    Calculated from 40 synthetic observations, not pharmaceutical measurements. The same samples appear in both panels, mean-centred without variance scaling; with only two variables, keeping both components preserves all the variation.

    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 sampleWhat the identity procedure should establish
    Independent authentic lactose lotCan expected target variation be accepted?
    Relevant non-target excipientCan the procedure reject a plausible alternative?
    Authentic lactose from a new supplierDoes the supported domain cover this variation?
    Mixture or adulterated sampleWhat 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

    ApproachInformation used to develop itTypical outputEvidence needed for the proposed use
    PCA explorationX; labels can inform interpretation afterwardScores, loadings, explained variance and residualsStability of patterns, measurement understanding and investigation of confounding
    Material class modelX and authenticated membership informationCompatibility with a defined classIndependent target lots, non-target challenges and justified decision rules
    PLS regressionX paired with a numerical reference YPredicted quantityIndependent 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

    1. PC1 explains most of the variance. Why might it still be a poor predictor of water content?
    2. Two samples overlap in a PC1–PC2 plot. What differences could remain hidden?
    3. Why does colouring a PCA plot by material name not make the PCA calculation supervised?
    4. A sample fits two material class models. What should the procedure specify before such a sample arrives?
    5. 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.