How to calculate the Variable Importance in Projection from outputs of PLSREGRESS?
27 views (last 30 days)
Show older comments
MathWorks Support Team
on 1 Feb 2019
Edited: MathWorks Support Team
on 2 Sep 2022
I want to estimate the importance of each variable to my Partial Least Squares (PLS) Regression model for variable selection. I am aware that the PLS projection finds those components that maximize the covariance between X and Y.
How can I calculate the "Variable Importance in Projection" from the output of the PLSREGRESS function?
Accepted Answer
MathWorks Support Team
on 2 Sep 2022
Edited: MathWorks Support Team
on 2 Sep 2022
By calculating the Variable Importance in Projection (VIP) you obtain scores that estimate the importance of each variable, see https://wiki.eigenvector.com/index.php?title=Vip.
Let us first load example data of near infrared (NIR) spectral intensities of 60 samples of gasoline at 401 wavelengths, and their octane ratings and perform PLS regression with ten components using the PLSREGRESS function like:
load spectra
X = NIR;
Y = octane;
NCOMP = 10;
[XL,YL,XS,YS,beta,pctvar,mse,stats] = plsregress(X,Y,NCOMP);
Note that the PLSREGRESS function uses SIMPLS as its main algorithm to calculate the predictor and observation loadings and scores. The VIP scores can be calculated directly from the obtained outputs:
% Calculate normalized PLS weights
W0 = bsxfun(@rdivide,stats.W,sqrt(sum(stats.W.^2,1)));
% Calculate the product of summed squares of XS and YL
sumSq = sum(XS.^2,1).*sum(YL.^2,1);
% Calculate VIP scores for NCOMP components
vipScores = sqrt(size(XL,1) * sum(bsxfun(@times,sumSq,W0.^2),2) ./ sum(sumSq,2));
If you are interested how the number of considered components affects this result, you can calculate the VIP scores for each cumulative PLS submodel, e.g. for component 1, components 1:2, ..., 1:NCOMP.
% Calculate VIP scores cumulatively for NCOMP components
vipScoresCum = sqrt(size(XL,1) * sum(bsxfun(@times,sumSq,W0.^2),2) ./ cumsum(sumSq,2));
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!