[R] Error predict with lda and cross validation
Uwe Ligges
ligges at statistik.tu-dortmund.de
Tue Jan 17 15:14:38 CET 2012
On 17.01.2012 14:54, Riccardo Romoli wrote:
> Hi, I use the lda function from the MASS package to classify some
> samples according to some chemical properties. If I run lda without
> cross validation all is ok but, if I run lda with cross validation, the
> R consol say:
>
> resLDA <- ldaRedOx <- lda(Activity ~ TRedOx[,1:6], CV=TRUE,
> data=dfDataRedOx, subset=train)
> predLDA <- predict(resLDA, newdata=dfDataRedOx[-train,])$class
>
> > predLDA <- predict(resLDA, newdata=dfDataRedOx[-train,])$class
> Error in UseMethod("predict") :
> no applicable method for 'predict' applied to an object of class "list"
> >
>
> How should I use predict function with lda with the cross validation?
See ?lda : it has a very different output if CV=TRUE is used. Hence you
have to prepare it with CV=FALSE in order to make predictions again.
It does not make sense to ask LDA for a cross validation an run another
test later on, does it?
Uwe Ligges
>
> Best
> Riccardo
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list