[R] how to reconstruct the discriminant funciton from lda$prior, $means and $scaling

From: Janet Huang <jh_168_at_yahoo.com>
Date: Fri 24 Jun 2005 - 05:58:24 EST


Hi R folks,

How can I generate the discriment function from lda?

I have an unbalanced data set. one class has about 25 entries and another class has about 200 entries.

I used lda for classification
> z<- lda(V3 ~ V1+V2, data)
> z

Prior probabilities of groups:

         0 1
0.91111111 0.08888889

Group means:

         V1 V2
0 0.4445161 0.04723951
1 0.4058900 0.06934000

Coefficients of linear discriminants:

         LD1
V1 -30.24734
V2 12.56484

predict(z) only give me 11 errors.

I used the following equations to reconstruct the discrimiat function:

>gmean <- z$prior %*% z$means
>const <- as.numeric(gmean %*% z$scaling)
>slope <- -z$scaling[1]/z$scaling[2]
>intercept <- const/z$scaling[2]
>abline(intercept, slope)

however, this line gives about 50 errors, not the same one used by the predict(z).

Any suggestions?

Thanks.
Janet



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jun 24 06:03:43 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:01 EST