I am looking for the exact formula for the coefficients of linear discriminants in lda()
from the package MASS
.
Consider the following data set.
set.seed(1)
sample<-data.frame(X=c(rnorm(40,-1),rnorm(40,1)),Class=c(rep("First",40),rep("Second",40)))
library(MASS)
lda.fit<-lda(Class~X,data=sample)
lda.fit
contains the following data.
Call:
lda(Class ~ X, data = sample)
Prior probabilities of groups:
First Second
0.5 0.5
Group means:
X
First -0.9079738
Second 1.1202668
Coefficients of linear discriminants:
LD1
X 1.103193
What is the exact formula used to calculate the coefficients of linear discriminants? How is 1.103193
calculated?
Any help is much appreciated!
P.S. I saw many answers on this website about LDA, but I am not able to find the exact formula used in lda()
from the MASS
package.