Charles, You should not be treating the classes as numeric (is virginica really three times setosa?). Q^2 and/or R^2 are not appropriate for classification.
Max On Sat, Mar 2, 2013 at 5:21 PM, Charles Determan Jr <deter...@umn.edu>wrote: > I have discovered on of my errors. The timematrix was unnecessary and an > unfortunate habit I brought from another package. The following provides > the same R2 values as it should, however, I still don't know how to > retrieve Q2 values. Any insight would again be appreciated: > > library(caret) > library(pls) > > data(iris) > > #needed to convert to numeric in order to do regression > #I don't fully understand this but if I left as a factor I would get an > error following the summary function > iris$Species=as.numeric(iris$Species) > inTrain1=createDataPartition(y=iris$Species, > p=.75, > list=FALSE) > > training1=iris[inTrain1,] > testing1=iris[-inTrain1,] > > ctrl1=trainControl(method="cv", > number=10) > > plsFit2=train(Species~., > data=training1, > method="pls", > trControl=ctrl1, > metric="Rsquared", > preProc=c("scale")) > > data(iris) > training1=iris[inTrain1,] > datvars=training1[,1:4] > dat.sc=scale(datvars) > > pls.dat=plsr(as.numeric(training1$Species)~dat.sc, > ncomp=3, method="oscorespls", data=training1) > > x=crossval(pls.dat, segments=10) > > summary(x) > summary(plsFit2) > > Regards, > Charles > > On Sat, Mar 2, 2013 at 3:55 PM, Charles Determan Jr <deter...@umn.edu > >wrote: > > > Greetings, > > > > I have been exploring the use of the caret package to conduct some plsda > > modeling. Previously, I have come across methods that result in a R2 and > > Q2 for the model. Using the 'iris' data set, I wanted to see if I could > > accomplish this with the caret package. I use the following code: > > > > library(caret) > > data(iris) > > > > #needed to convert to numeric in order to do regression > > #I don't fully understand this but if I left as a factor I would get an > > error following the summary function > > iris$Species=as.numeric(iris$Species) > > inTrain1=createDataPartition(y=iris$Species, > > p=.75, > > list=FALSE) > > > > training1=iris[inTrain1,] > > testing1=iris[-inTrain1,] > > > > ctrl1=trainControl(method="cv", > > number=10) > > > > plsFit2=train(Species~., > > data=training1, > > method="pls", > > trControl=ctrl1, > > metric="Rsquared", > > preProc=c("scale")) > > > > data(iris) > > training1=iris[inTrain1,] > > datvars=training1[,1:4] > > dat.sc=scale(datvars) > > > > n=nrow(dat.sc) > > dat.indices=seq(1,n) > > > > timematrix=with(training1, > > classvec2classmat(Species[dat.indices])) > > > > pls.dat=plsr(timematrix ~ dat.sc, > > ncomp=3, method="oscorespls", data=training1) > > > > x=crossval(pls.dat, segments=10) > > > > summary(x) > > summary(plsFit2) > > > > I see two different R2 values and I cannot figure out how to get the Q2 > > value. Any insight as to what my errors may be would be appreciated. > > > > Regards, > > > > -- > > Charles > > > > > > -- > Charles Determan > Integrated Biosciences PhD Student > University of Minnesota > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Max [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.