[R] Compute R2 and Q2 in PLS with pls.pcr package
aconesa at cipf.es
Tue Oct 23 16:05:32 CEST 2007
I am using the mvr function of the package pls.pcr to compute PLS
resgression using a X matrix of gene expression variables and a Y matrix
of medical varaibles.
I would like to obtain the R2 (sum of squares captured by the model) and
Q2 (proportion of total sum of squares captured in leave-one-out cross
validation) of the model.
I am not sure if there are specific slots in the output of the mvr
function that give these parameters (RMS and R2 parameters are given for
each variable of Y). I have tried to compute it myself from the ouput of
mvr but I am not sure if the values of Ypred within the validat slot are
the predictions of each observation of Y when leave-one-out cross
validation is applied.
My code is as follows:
> mypls <- mvr(Xtrain, Ytrain, method="SIMPLS", validation="CV",
> Xhat <- mypls$training$Xscores %*% t(mypls$training$Xload)
> R2 <- 1-(sum((Xhat-Xtrain)^2)/sum(Xtrain^2))
> Q2 <- 1-(sum((Ytrain-mypls$validat$Ypred[,,1])^2)/sum(Ytrain^2)
Is this right?
Ana Conesa, PhD
Centro de Investigación Príncipe Felipe
Avda. Autopista Saler 16
46013 Valencia Spain
CAMDA2007 Conference @ CIPF
More information about the R-help