Janet Huang
2005-Jun-23 19:58 UTC
[R] how to reconstruct the discriminant funciton from lda$prior, $means and $scaling
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) > zPrior 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