Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I have a matrix with 1024 features and 10000 samples with a label vector of three different classes. I use R MASS library lda function to compute the model and get the coefficients for linear discriminants:

> library (MASS)
> 
> ldamodel = lda(data$X, data$y)
> head (ldamodel$scaling)
             LD1         LD2
V5  -0.053074978  0.14565211
V6  -0.009618016 -0.11198306
V7  -0.003863230  0.28189459
V8   0.063191889 -0.26726050
V9  -0.029950632  0.16121364
V10  0.017988965 -0.01584389
...

The model has two linear discriminants, which is ok. But I'd like to know, if it is possible make the lda function create more than two linear discriminants and how to do it in R? I'm not yet very faimiliar with LDA, so I'm sorry, if this question is a statistical nonsense.

share|improve this question

2 Answers

up vote 2 down vote accepted

LDA finds at most $k - 1$ linear discriminants, where $k$ is the number of classes. In your data you state you have three classes hence only 2 linear discriminants can be resolved.

share|improve this answer
1  
In addition, there are at most as many linear discriminants as there are predictors (features). – caracal May 29 '12 at 20:47

I could easily produce more than two LD so I guess here the issue is your call lda(data$X, data$y) or your data. What are $X$ and $y$ in your case?

To me it looks like you have 1024 classes and two predictors.

If data is a 10,000 x $m$ data.frame and C is your vector of classes (length 10,000) you have to call the function as follows

ldamodel <- lda(data, C)

Then you should see $m$ LD. I guess the problem is that your data$y has only two columns. Now if you have only two predictors, you cannot get more linear discriminants...

EDIT: Sorry about this answer, I got confused between the number of classes and the number of predictors. You should see as many LD as unique(C) - 1, and not $m$. The length of each of them should be $m$. And of course, you cannot get more linear discriminants as unique(C) - 1.

share|improve this answer
$X$ is a matrix with 10000 rows and 1024 columns. $y$ is a factor vector of length 10000 with three different values. What did you mean by guessing that $y$ has only two columns? – Timo May 29 '12 at 20:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.