[R] Regularized Discriminant Analysis scores, anyone?

Matthew Fagan mef2153 at columbia.edu
Sun Jun 2 05:01:45 CEST 2013


Hi all,

I am attempting to do Regularized Discriminant Analysis (RDA) on a large 
dataset, and I want to extract the RDA  discriminant score matrix.  But 
the predict function in the "klaR" package, unlike the predict function 
for LDA in the "MASS" package, doesn't seem to give me an option to 
extract the scores.  Any suggestions?

i have already tried (and failed; ran out of 16 GB of memory) to do this 
with the "rda" package: don't know why, but the klaR package seems to be 
much more efficient with memory.  I have included an example below:

library(klaR)
library(MASS)

data(iris)

x <- rda(Species ~ ., data = iris, gamma = 0.05, lambda = 0.2)
rda1<-predict(x, iris[, 1:4])
str(rda1)

#  This gets you an object with posterior probabilities and classes, but 
no discriminant scores!

#  if you run lda

y <- lda(Species ~ ., data = iris)
lda1<-predict(y, iris[, 1:4])
str(lda1)

head(lda1$x)  #  gets you the discriminant scores for the LDA.  But how 
to do this for RDA?

#  curiously, the QDA function in MASS has this same problem, although 
you can get around it using the rrcov package.

Regards, and thank very much for any help,
Matt



More information about the R-help mailing list