← All algorithms

Regression

Partial Least Squares Regression

2023-12-14

PCA (Principal Component Analysis) aims to find a projection plane that maximizes the linear combination (i.e., covariance) of source parameters. To achieve this, it obtains the eigenvectors corresponding to the maximum eigenvalue of the covariance matrix. Meanwhile, Partial Least Squares (PLS) is used primarily when there are more variables than the number of data points, to create a regression model through dimensionality reduction.

​

When expressed in mathematical terms, for each sample i out of a total of n samples, let xi represent a d-dimensional Source parameter vector, and yi represent a k-dimensional Response parameter vector. Then, X = [nxd] and Y = [nxk] become matrices, where X is all the source data and Y is the observed value.

Introducing t to represent the predicted value as a linear combination of X using a weight vector w [dx1], t is a vector of size n called the PLS variable.

t = Xw

​and T = [t1,t2, ...] is the matrix of combination of the vector t.

From the definition of the covariance matrix and coefficient of determination, R-squared,

​\(Cov(X,Y)\&=S_{XY}=\dfrac{X^TY}{n-1}\)

\(Cov(X,X)\&=S_{XX}=Var(X)\)

\(R-Squared=Corr(X,Y)=\dfrac{S_{XY}}{\sqrt{S_{XX}}\sqrt{S_{YY}}}\)​​​

By multiplying and dividing same matrix to the covariance matrix, STY, between the prediction matrix, T, and the measurements Y as below, 

\(Cov(T,Y)=\dfrac{S_{TY}\sqrt{S_{TT}}\sqrt{S_{YY}}}{\sqrt{S_{TT}}\sqrt{S_{YY}}}\)​​​

\(=Corr(T,Y)\sqrt{S_{TT}}\sqrt{S_{YY}}\)​​

The last term is a value of the Response itself, independent of the parameter w. The second term is the projection of the Source Parameter w onto Var(Xw). The first term represents the correlation between the observed and predicted values. In other words, maximizing Cov(T, Y) means finding the value of w that maximizes the variance and maximizes the correlation between the observed and predicted values. Geometrically, this can be interpreted as performing PCA (Principal Component Analysis) and finding the value of w that maximizes the correlation between the observed and predicted values.

\(Cov(T,Y)=\dfrac{T^TY}{n-1}\)

\(=\dfrac{(Xw)^TY}{n-1}\)

\(=\dfrac{w^T(X^TY)}{n-1}\)

\(=\dfrac{\parallel w\parallel \cdot \parallel X^TY\parallel \cos \theta}{n-1}\)

In other words, the θ must be zero to maximize Cov(T, Y) which means

||w|| and ||XTY|| must be parallel to each other such that

\(w=\dfrac{X^TY}{\parallel X^TY\parallel }\)

The way performs PLS is called NIPLS (Nonlinear iterative partial least square) and following the next steps.

Step 1. Initialize w as follows . Here y is any arbitrary column of the matrix Y [nxk], y=[nx1]. Since X is the matrix of size [nxd], w becomes [dx1] vector.

\(w=\dfrac{X^Ty}{\parallel X^Ty\parallel }\)

Step 2. Calculate t an ephemeral PLS variable as follows.

\(t=Xw\)

Step 3. Find the slope, b, between the matrix Y and the PLS variable, t, by using Least Square.  Update Y matrix as follows. In other words, the new Y becomes the remaining parts of the Y after the portion of tbT is accounted. The name "Partial" of PLS came from here.

\(b=\dfrac{t^TY}{t^Tt}\)​​

\(Y=Y-tb^T\)​

Step 4. Find the slope, p, between the matrix X and the PLS variable, t, by using Least Square. Update matrix X as follows. The new X becomes the remaining parts of the X after tpT is accounted.

\(p=\dfrac{t^TX}{t^Tt}\)​​

\(X=X-tp^T\)​

Step 5. Repeat Step 1~4 using new X and Y matrix to update the PLS variable t, associated the Matrix Y, and the coefficient, b, between them. At the end after several iteration, the remaining Y and X converge to zero.

Step 6. Prediction of Y for error calculation can be obtained from the linear sum of the PLS variable, t, and the slope, b, calculated at each iteration.

\(Y=t_1b_1^T+t_2b_2^T+t_3b_3^T+\dots\)

Step 7. In order to predict the vector, y', for any new Source vector, x', first calculate the PLS variable, t' , as follows:

\(t'_1=x'p_1\)

\(t'_2=x'p_2\)

\(t'_3=x'p_3\)

here the variable t' are all constant after the result of a matrix inner product [1xd][dx1] .

​The inference of y' is the sum of the slope vectors, b of size [1xk], weighted by the PLS variable t'.

\(y'=t'_1b_1^T+t'_2b_2^T+t'_3b_3^T+\dots\)​

In the excel worksheet attached, we use the case where the number of Source parameters is 7 (d=7) but only has 3 data points (k=3) to demonstrate PLS regression. 

​

​

To summarize, the method involves introducing the PLS variable t to find the best slope b that represents Y between Y and t, and the best slope p that represents X between X and t. By iteratively calculating new t, b, and p for the remaining variances of X and Y, the method approximates the total variance.

​

<Note> For comparison purpose, we can use standard Linear Regression using Matrix Inversion.

Step 1. Normalize the data with respect to the mean

Step 2. Calculate the A = XTX , then perform normalization as below to perform inverse matrix calculation

\(A=A-1.0e^{-5}\dfrac{\text{trace A}}{\text{dim A}}\circ \text{I}\)

​Step 3. Calculate W = A-1(XTY). Here, W becomes a [dxk] matrix.

(In the case of PLS, the size of the slope is [dx1] and it is used only to obtain the PLS variable t from X.)

​Step 4. The inference of Y' = XW.

The result, as shown below, even if the number of data is less than the coefficient (dxk) you want to calculate, point estimation calculation is possible through Matrix Inversion.

​

​