Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical & Research SuppliesReagents, PPE & instruments — chain-of-custody documented.Fast, traceable sourcing built for regulated research environments, from bench consumables to instrumentation.Shop lac.us CodeCASRAIlac.us

What Is Partial Least Squares Regression? Definition, Formula, Example

PLS regression defined, with the first component worked by hand (n = 5) and runnable R and Python code; also separates PLS-SEM and the least squares line.

Written and maintained by CASRAI Editorial Board

Last updated

Partial least squares (PLS) regression is a method for predicting one or more outcome variables from many predictors that are correlated with each other, or that outnumber the observations. It compresses the predictors into a few latent components, and, unlike principal component regression, it builds those components using the outcome as well as the predictors. This page defines it, shows the first component computed by hand with every number, and gives code you can run in Excel, R and Python.

Definition in one paragraph

PLS regression projects the predictor matrix X and the response matrix Y into new, low-dimensional spaces chosen so that the components of X have maximum covariance with Y. Ordinary least squares (OLS) needs a well-conditioned X’X; PLS does not, which is why it is the standard tool in chemometrics (for example, predicting a concentration from hundreds of correlated near-infrared absorbance readings) and is used wherever p, the number of predictors, exceeds n, the number of observations. The method was introduced by Herman Wold and developed with Svante Wold (Wikipedia, “Partial least squares regression”, read 2026-11-07).

PLS regression vs PLS-SEM vs the least squares line

Three different things share the words “least squares”, and searchers routinely land on the wrong one.

What does a least squares regression line do?

A least squares regression line is the straight line through a scatterplot that minimises the sum of the squared vertical distances (residuals) between observed and predicted values. PLS uses the same squared-error idea, but fits it on latent components rather than directly on the raw predictors. See regression analysis for the basics.

What is partial least squares structural equation modelling (PLS-SEM)?

PLS-SEM, also called PLS path modelling, is a different technique: it estimates a network of relationships among latent constructs measured by questionnaire items, common in business and management research. It is not the regression described here. For its reliability and validity statistics see average variance extracted, and for the general model family see path analysis. Wikipedia keeps a separate article, “Partial least squares path modeling”.

Formula, with every symbol explained

PLS regression decomposes both matrices:

X = T P’ + E and Y = U Q’ + F

  • X: n × p matrix of predictors (centred); Y: n × m matrix of responses (centred).
  • T and U: n × l matrices of scores, the values of the l latent components for each observation.
  • P (p × l) and Q (m × l): loadings, which say how each original variable contributes to each component.
  • E and F: residual (error) matrices not captured by the l components.

For a single response (PLS1), the first weight vector is proportional to X’y, the scores are t = Xw, and the matrix X is then deflated (the part explained by t is subtracted) before the next component is extracted. The final coefficients are B = W(P’W)-1q. If you keep l equal to the rank of X, the result is the ordinary least squares solution (Wikipedia, read 2026-11-07).

Worked example: the first PLS1 component, with the arithmetic

This is a deliberately tiny, invented dataset (n = 5, two predictors) chosen so every step can be checked by hand. It is a teaching illustration, not real data.

Obs. x1 x2 y
1 1 2 2
2 2 1 1
3 3 4 4
4 4 3 3
5 5 5 5

Step 1, centre. The means are x̄1 = 3, x̄2 = 3, ȳ = 3. Centred x1 = (−2, −1, 0, 1, 2); centred x2 = (−1, −2, 1, 0, 2); centred y = (−1, −2, 1, 0, 2).

Step 2, weight vector. X’y = (x1·y, x2·y) = ((−2)(−1) + (−1)(−2) + 0 + 0 + 2·2, (−1)(−1) + (−2)(−2) + 1·1 + 0 + 2·2) = (8, 10). Its length is √(8² + 10²) = √164 = 12.806. Normalised, w = (8, 10)/12.806 = (0.6247, 0.7809).

Step 3, scores. t = 0.6247·x1c + 0.7809·x2c, giving t = (−2.0303, −2.1864, 0.7809, 0.6247, 2.8111). Then t’t = 17.805.

Step 4, loadings. The y-loading is q = y’t / t’t = 12.806 / 17.805 = 0.7193. The x-loadings are p = X’t / t’t = (0.7017, 0.7193).

Step 5, coefficients (one component). b = w·q = (0.4493, 0.5616). Predictions are ŷ = 3 + 0.4493(x1 − 3) + 0.5616(x2 − 3); for observation 1 this is 3 + 0.4493(−2) + 0.5616(−1) = 1.540. One component explains 1 − Σ(y − ŷ)²/Σy² = 92.1% of the variance of y.

A second component would be extracted from the deflated matrix X − t p’. With only two predictors, two components would reproduce ordinary least squares exactly, which is the rank rule above in action.

Interpretation: reading the output

Output What it tells you Source for the convention
Number of components Chosen by resampling, for example the component count that minimises cross-validated RMSE, not by fit on the training data. tidymodels PLS tutorial (10 repeats of 10-fold cross-validation)
Percent variance explained (X and Y) How much of each matrix the components capture; MATLAB returns it as PCTVAR. MathWorks plsregress
VIP score ≥ 1 The predictor contributes more than average to the model; the MathWorks NIR example uses this cut-off to flag wavelengths. MathWorks plsregress example
Loadings Which original variables define each component. Wikipedia, PLS regression

Is there a good p value for a PLS or any regression?

There is no universal “good” p value. In OLS, the conventional significance level of 0.05 is a field convention you should set before the analysis, not a property of the model; see hypothesis testing in linear regression. Standard PLS output does not give coefficient p values; judge it by cross-validated error, and use resampling if you need uncertainty on coefficients.

PLS vs principal component regression vs OLS

Method How components or coefficients are built Typical situation
OLS Directly from X’X; needs predictors that are not collinear and p < n. Few, independent predictors
Principal component regression Components come from X alone (PCA), then y is regressed on them. Collinear predictors, outcome ignored when compressing
PLS regression Components use both X and the outcome, maximising covariance with Y. Collinear predictors or p > n, prediction goal

The PCA-versus-PLS contrast is stated in the tidymodels tutorial: PLS, unlike PCA, also incorporates the outcome data when creating the components.

How is least squares used for classification?

For a categorical outcome, PLS is run on dummy-coded class labels; this variant is called PLS-DA (discriminant analysis) and assigns each observation to the class with the highest predicted value (Wikipedia, PLS regression, read 2026-11-07). For a standard classifier on a binary outcome, see the logit model.

Assumptions and common mistakes

  • Not scaling. PLS works on variances and covariances, so predictors on different scales should be standardised first; MATLAB’s plsregress centres the data but does not rescale it, so call zscore yourself (MathWorks, tidymodels).
  • Choosing components on the training fit. Variance explained always rises with more components; pick the number by cross-validation.
  • Treating it as inferential. PLS is built for prediction; interpret loadings and VIP scores descriptively.
  • Confusing it with PLS-SEM. See the disambiguation above.
  • Leaking information. Do the centring, scaling and component selection inside each cross-validation fold.

How to report it (APA style)

A pattern consistent with APA 7th practice, with bracketed values to replace with your own output:

Partial least squares regression (SIMPLS algorithm) was fitted to [n] observations and [p] standardised predictors. The number of components ([l]) was chosen by [k]-fold cross-validation, minimising RMSE. The model explained [x]% of the variance in [outcome], with cross-validated RMSE = [value] (training RMSE = [value]).

Name the software and version, state whether predictors were scaled, and report the cross-validated error, not only the fitted R².

How to calculate it in Excel, R or Python

Excel

Excel has no built-in PLS function, but the first component above can be reproduced with array formulas. With centred predictors in B2:C6 and centred y in D2:D6: weights =MMULT(TRANSPOSE(B2:C6),D2:D6) (gives 8 and 10), then divide by =SQRT(SUMSQ(...)) of that vector, and scores with =MMULT(B2:C6,w). For standard OLS output see ANOVA in Excel.

R

library(pls)
d <- data.frame(x1 = c(1,2,3,4,5), x2 = c(2,1,4,3,5), y = c(2,1,4,3,5))
fit <- plsr(y ~ x1 + x2, data = d, ncomp = 1, scale = FALSE, validation = "LOO")
coef(fit)      # 0.4493, 0.5616
explvar(fit)   # percent variance explained in X

Python

import numpy as np
from sklearn.cross_decomposition import PLSRegression
X = np.array([[1,2],[2,1],[3,4],[4,3],[5,5]], float)
y = np.array([2,1,4,3,5], float)
m = PLSRegression(n_components=1, scale=False).fit(X, y)
print(np.ravel(m.coef_))   # [0.4493 0.5616]
print(m.predict(X).ravel())

The coefficients match the hand calculation above. For multivariate follow-ups see MANOVA in R.

FAQ

What is partial least squares regression used for?

Prediction when predictors are numerous and correlated, such as spectra in chemometrics.

How many components should I keep?

The number that minimises cross-validated error, not the number that maximises training fit.

What is the difference between PLS regression and PLS-SEM?

PLS regression predicts outcomes from predictors; PLS-SEM estimates relations among latent constructs.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about What Is Partial Least Squares Regression? Definition, Formula, Example

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →