On Tue, 1 Apr 2003, array chip wrote:
>
> I used the "lda" function in the MASS library of S-Plus (R) to do
a
> linear discriminant analysis, and got the linear coefficients, say b1
> and b2 for the 2 predictors x1 and x2. I have trouble to calculate the
> discrimiant scores for each observation, I used 3 ways to try to repeat
> the scores returned by the "predict" function in S-Plus:
>
> 1. b1*x1+b2*x2
> 2. b1*(x1-mean of x1)+b2*(x2-mean of x2)
> 3. b1* standardized x1+b2*standardized x2 (standardize: mean 0 &
variance 1)
>
> none of the above procedures can repeat the scores returned by the
> "predict" function. However, method 2 & 3 can predict the
classes
> correctly if using 0 as cutoff, juts like using the "predict
function".
You've sent this to R-help, but S-PLUS (sic) and R are different as is my
lda() function in each. MASS is a book, and it contains the details,
as does the code.
> What should be the correct formula to compute the scores for each
> observation?
>
> BTW, how to retrieve the linear coefficients from an lda object? I
can't
> retrieve it by using @coef, @coefficients, etc.
Of course not: in R these are not S4 classes. You could read the help
page to see what lda() actually computes.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595