Hi,
I am trying to solve a discriminant analysis in the same way as SPSS does it.
I mean, given an amount of data, to train the discriminant analysis I obtain the
Fisher's discriminant functions, an array of coefficients per group, so if I
have 8 groups I get 8 linear functions, that allow me to operate with them
easily and without a great cost of time.
My main problem is that I need to give a prediction over an application that
is running in real time, and I can't expend a lot of time on online
operations. That's why the solution given by SPSS is a good one, as it
provides a matrix and the only operation needed is nearly just dot matrices. But
it has a great disadvantage, as it is propietary, and runs over Windows OS, and
I need it running over Linux OS to automate some operations.
The most reliable application for statistics was R-project, and I decided to
adopt it as the base platform for all the statistics operations (and I think it
has been a good choice). But ... how could I obtain the same matrix given by
SPSS with R??
I've tried to do it with R, but I only get the canonical matrices as the
result, n-1 arrays of coefficients for my n groups, and after that I have to use
'predict' to get the sample classification. This is right but it takes
about 0.6 seconds to solve this operations: raising the R environment and making
the operations, and it's too much. Even, I tested rpy module (over Python)
to make a kind of server which could just save the time spent on raising the R
environment and spend just the operations time, but it was not as I thought and
was a fruitless work.
For example (the data is not real and not good but works, just an example):
>From Linux console:
> cat data.txt
group v1 v2 v3
1 2 3 5
1 2 4 6
2 11 8 7
2 9 9 10
3 20 14 13
3 21 15 17
>From R console:
> data <- read.table("data.txt", header=T)
> data.lda <- lda(group ~ ., data=data)
> data.lda
Call:
lda(group ~ (v1 + v2 + v3), data = tmp.data)
Prior probabilities of groups:
1 2 3
0.3333333 0.3333333 0.3333333
Group means:
v1 v2 v3
1 2.0 3.5 5.5
2 10.0 8.5 8.5
3 20.5 14.5 15.0
Coefficients of linear discriminants:
LD1 LD2
v1 0.8294354 0.6168736
v2 2.8623498 -1.7696711
v3 -0.7612283 0.8423363
Proportion of trace:
LD1 LD2
0.9984 0.0016
In this example, I get 2 functions: LD1 and LD2 as the canonical functions for
3 groups, and what I'd need is 3 functions for my 3 groups (Fisher's
discriminant functions).
Has anyone got the same problem as me?? If it has, how was it solved?? Which
library was taken?? ... How could I convert the canonical functions (n-1
functions per n groups) into Fisher's functions (n functions per n groups)??
Thanks.
Regards.
Carlos Niharra López
---------------------------------
[[alternative HTML version deleted]]