Different coefficients of linear discriminants with the same raw data

I have just tried two ways to perform a linear discriminant analysis.

Mode 1

This is the data, divided in two tables (printed from screen using R commander):

They belong respectively to the two already known groups.

I ran the next code to get the coefficients and critic value of the function:

m1=cov.wt(Craneos1)$center m1=data.matrix(m1) m2=cov.wt(Craneos2)$center
m2=data.matrix(m2)
D=((nrow(Craneos1)-1)*var(Craneos1)+(nrow(Craneos2)-1)*var(Craneos2))/30
d=solve(D)%*%(m1-m2)
d # Estos son los coeficientes de la función
0.5*t(m1+m2)%*%d # Este es el punto crítico


I get the next results:

> d # Coefficients of the discriminant analysis
[,1]
x1 -0.089306662
x2  0.155774683
x3  0.005231617
x4 -0.177194601
x5 -0.177408670

> 0.5*t(m1+m2)%*%d # Este es el punto crítico
[,1]
[1,] -30.46349


These results are exactly the same as those ones that appeared in a book I am studying.

Mode 2

I reordered the last two tables into only one with the first column as a factor:

In this case, I used the function lda (from the package MASS), since it has been widely used in examples on internet.

I ran the next command:

lda(group~.,data=Datos)


Which displayed the next results:

> lda(group~.,data=Datos)
Call:
lda(group ~ ., data = Datos)

Prior probabilities of groups:
CRANEOS1 CRANEOS2
0.53125  0.46875

Group means:
X1       X2       X3       X4       X5
CRANEOS1 174.8235 139.3529 132.0000 69.82353 130.3529
CRANEOS2 185.7333 138.7333 134.7667 76.46667 137.5000

Coefficients of linear discriminants:
LD1
X1  0.047726591
X2 -0.083247929
X3 -0.002795841
X4  0.094695000
X5  0.094809401


My questions are:

Is there anything wrong in the code displayed above?

Why are the both coefficients different depending on the mode used?

Which of them must be more reliable?

How can I get the critic value using the Mode 2?

• Looks like the coefficients are actually identical, up to a constant factor. – amoeba says Reinstate Monica Mar 5 '15 at 12:00
• Actually, they seem to be the same. However they're not. I have also tried with different data and their values are clearly different, much wider than those ones exposed in this example... – antecessor Mar 5 '15 at 12:03
• They are identical, up to a constant factor -1.8712. – amoeba says Reinstate Monica Mar 5 '15 at 12:05
• Oh, I see. And how can this difference be achieved comparing both methods? – antecessor Mar 5 '15 at 12:19
• The length of the discriminant vector is essentially arbitrary and does not matter. Perhaps your own algorithm and lda() function use different normalizations. – amoeba says Reinstate Monica Mar 5 '15 at 14:45