How to obtain predictor scores from standardized inputs after partial least squares?
2 views (last 30 days)
Show older comments
The function plsregress() returns the PLS components (XS) after linear transformation of inputs. However, after performing PLS on a given data set [X,y], how can one transform a new input x to its corresponding PLS component? The documentation mentions
, where X0 is standardized X and W is the weight vector obtained by performing PLS transformation. I cannot validate this on the spectra data set.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/871880/image.png)
0 Comments
Answers (1)
Akshat
on 17 Nov 2023
Hi Maaz,
As per my understanding of the question, you want to fit a new input “x” using the weights generated by your data set, “[X,y]”.
As you have rightly identified, we need to use “standardized” version of our new input. That is, the input “x” must be standardized. The process of standardization is done to make the data keep its original properties and make the mean 0 and standard deviation 1.
This can be found in the algorithms section of the documentation of “PLSregress”, the documentation is available in the below link: https://www.mathworks.com/help/stats/plsregress.html#mw_66343793-51f5-466d-b146-3d09043613a1
We can perform this action using the z-score, using the function “zscore”. This function is specifically designed to standardize vectors. You can find the documentation here:
Then, using the following code, I think you can fit the weights on the standardized array.
% Assume X and y are your original data matrices
% Assume x is your new input matrix
% Assume ncomp is the number of PLS components
% Perform PLS regression on the original data
[XL,yl,XS,YS,beta,pctvar,mse,stats] = plsregress(X,y,ncomp);
% Standardize the new input x
x0 = zscore(x);
% Transform the standardized new input to its PLS components
XS_new = x0 * stats.W;
Feel free to follow up in case you have further queries!
Hope this helps!
Regards
Akshat
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!