[R] Compute R2 and Q2 in PLS with pls.pcr package

Ana Conesa aconesa at cipf.es
Tue Oct 23 16:05:32 CEST 2007


Dear list

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", 
ncomp=1, niter=nrow(Ytrain))
 > 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?

Thank you

Ana

-------------------------------------------

Ana Conesa, PhD

Bioinformatics Department

Centro de Investigación Príncipe Felipe

Avda. Autopista Saler 16

46013 Valencia Spain

http://bioinfo.cipf.es

===========================================

CAMDA2007 Conference @ CIPF

http://camda.bioinfo.cipf.es



More information about the R-help mailing list