PLS-DA weight calculation


Does anyone know how to calculate X-weights (R or W*) in PLSDA?


I have P matrix, but I don´t find W matrix in plsda results.

Thanks very much!!!


Dear @enzo,

Ah, this is a technical question! See this code here: from line 579. The W are the loading vectors. I am not sure what you are trying to achieve, but potentially you could use the predict() function from a PLS-DA model.

I hope that helps,


Thanks very much for your reply,

I think it is a obsession for me. I´m working on geochemical data where each sample belong to a class, so I´m trying to build a PLSDA model.

In my research team, specifically my PhD director wants to know how much each variable contributes to model, but further, he wants to know how much each variable contributes to each class. So, for the first question VIP of the whole model can be work. I could use VIP from vip function in MixOmics, but it is VIP for each variable in each component.

Some peoples of this team use a lot MatLab, but I don´t have enough knowledge with this software, additionally PLS tools is not a free code and my computer is not very good for a lot of data.

PLS tools in MatLab build the model and compute VIP for each variable on each class. MatLab is very useful, but unpractical for me with my conditions.

I would like also, to show we can use R to PLSDA as well as MatLab and to be more independent.

I achieved to build a code to calculate whole VIP from MixOmics plsda results, but I was wrong, because I used X-loadings rather than X-weights according this formula (Mendez et. al, 2020):

Or this one (Gosselin et al, 2010):

X-weights are not supplied by plsda function in MixOmics. I looked it up with predict() but I didn´t find it.

Also, I realized there are several formula to calculate VIP.

I hope don´t bother you with this problem.

Thanks very much,



Mendez, K.M., Broadhurst, D.I., and Reinke, S.N. (2020) Migrating from partial least squares discriminant analysis to artificial neural networks: a comparison of functionally equivalent visualisation and feature contribution tools using jupyter notebooks. Metabolomics, 16(2), 17.

Mehmood, T., Liland, K.H., Snipen, L., and Sæbø, S. (2012) A review of variable selection methods in partial least squares regression. Chemometrics and Intelligent Laboratory Systems, 118, 62-69.

Eriksson, L., Byrne, T., Johansson, E., Trygg, J., and Vikström, C. (2013) Multi-and megavariate data analysis basic principles and applications. Umetrics Academy.

Thank you @enzo,
I am flagging your message and will see what I can do to update our codes in due time. We are a bit busy right now with a major update for our book, so hopefully in a few months we can get onto this.