# How do I calculate the Q2Y cumulative from a PLS-DA in R?

   install.packages("DiscriMiner")

require(DiscriMiner)

out <- plsDA(X, Y, autosel = TRUE, comps = 2, validation = NULL, learn = NULL,
test = NULL, cv = "LOO", k = NULL, retain.models = FALSE)


I have 133 subjects ( 60 % control and 40 % disease). I can obtain my R2Y cumulative through out$R2, which is 0.45. However, when I do out$Q2, I get the Q2 for control (Q2.0) and for disease (Q2.4) and a global Q2. The average of the global Q2 is -0.15 which indicates that my model has no predictive relevance given the negative value. Please could somebody clarify how I would calculate Q2Y cumulative?

## 1 Answer

To calculate $$Q2Y$$ manually with the following formula:

$$Q2Y=1−∏_{i=1}^{N_{comp}}(1−Q2Y_i)$$

Using the package ropls you get it as an output of the model:

library(ropls)

data(iris)

mdl <- ropls::opls(iris[, 1:4], iris\$Species, crossvalI=nrow(iris))
plot(mdl)

PLS-DA
150 samples x 4 variables and 1 response
standard scaling of predictors and response(s)
R2X(cum) R2Y(cum) Q2(cum) RMSEE pre ort pR2Y  pQ2
Total    0.995    0.586    0.57 0.307   3   0 0.05 0.05 • Thank-you, I just found this package through a Google search! – undecided4567 Jul 4 '20 at 16:50