Variance contribution PLS-DA

I am using PLS-DA to build a discriminant model to classify a binary variable (coded as 0/1). Can you please tell me how extract the variance explained/contributed that each predictor contribute to the prediction model?
I am have a looked at the plotLoadings and selectVar but they seemed to not produce what I want.

Many thanks,

Hi @ph78,

Try with this code:

X <- srbct$gene
Y <- srbct$class
splsda.result <- splsda(X, Y, keepX = c(10,5)) # run the method

vip <- vip(splsda.result)

vip_comp1 <- vip[c(selectVar(splsda.result, comp = 1)$name ),"comp1"]
vip_comp2 <- vip[c(selectVar(splsda.result, comp = 2)$name ),"comp2"]

barplot(vip_comp1, beside = TRUE, ylim = c(0, 40), legend = rownames(vip_comp1),
        main = "VIP - Comp 1")

barplot(vip_comp2, beside = TRUE, ylim = c(0, 40), legend = rownames(vip_comp2),
        main = "VIP - Comp 2")


1 Like

Morning @ph78 ,

@christoa 's answer will get you what you want. I thought I would just chime in to clarify a couple things.

plotLoadings() uses a barplot to depict the contribution - or “loadings” - of each input variable has to the variates yielded by the sPL-DA model. The variates are essentially linear combinations of the input variables and the loadings are the coefficients of this linear combination (more info here).

If you wish to look at the proportion of predictor variance explained by each variate, the splsda object has a component prop_expl_var which will yield exactly that. In the above code, you would access this with:

VIP (Variable Importance in Projection) differs from the loading values as it measures the importance of each variable in explaining the predictors’ variance.

Hopefully this helped with your understanding a bit.