# [R] Still needing help with LDA

Christoph Lange clange at epost.de
Fri Apr 5 14:41:54 CEST 2002

```(reply to ripley at stats.ox.ac.uk)

> on wed, 3 apr 2002, christoph lange wrote:
>
> [...]
>
> > can anybody help me to get equivalent outputs of wilks' lambda in r as
> > in spss?
>
> perhaps you could explain to us exactly what spss does.  `exactly' because
> we've already seen that spss's equivalent of summary.manova does not do
> what it says it does ....  but one possibility is that you just need to do
> summary(manova(data ~ grouping), test="wilks"), which will test if there
> is a difference between the groups.  as in
>
> data(iris)
> x <- as.matrix(iris[-5])
> summary(manova(x ~ iris\$species), test="wilks")

Thanks a lot for your help so far. But, alas, I'm still stuck in the
statistical swamp of synonyms and other horrible things.

Below I send a sample output of SPSS's discriminant analysis.

What I'd need are measures for how much of the group differences one
DF explains, as the eigenvalues below (is this, perhaps, somehow
connected to what R puts out as "Proportion of trace"?)

A second thing would be something like the "structure matrix" below,
by some called loadings (that's what I meant with synonyms ...) to see
which variable contributes most to each function.

... hope I don't bother you too much.

Yours,

Christoph.

=========================================================================
eigenvalues

| -------- | ---------- | ------------- | ------------ | ----------
| function | eigenvalue | % of variance | cumulative % | canonical
|          |            |               |              | correlation
| -------- | ---------- | ------------- | ------------ | ----------
| 1        | 15.562(a)  | 81.3          | 81.3         | .969
| -------- | ---------- | ------------- | ------------ | ----------
| 2        | 2.564(a)   | 13.4          | 94.7         | .848
| -------- | ---------- | ------------- | ------------ | ----------
| 3        | .514(a)    | 2.7           | 97.3         | .583
| -------- | ---------- | ------------- | ------------ | ----------
| 4        | .265(a)    | 1.4           | 98.7         | .458
| -------- | ---------- | ------------- | ------------ | ----------
| 5        | .140(a)    | .7            | 99.5         | .350
| -------- | ---------- | ------------- | ------------ | ----------
| 6        | .069(a)    | .4            | 99.8         | .255
| -------- | ---------- | ------------- | ------------ | ----------
| 7        | .034(a)    | .2            | 100.0        | .181
| -------- | ---------- | ------------- | ------------ | ----------
| 8        | .002(a)    | .0            | 100.0        | .044
| -------- | ---------- | ------------- | ------------ | ----------

a first 8 canonical discriminant functions were used in the analysis.

wilks' lambda

| ------------------- | ------------- | ---------- | -- | ---- |
| test of function(s) | wilks' lambda | chi-square | df | sig. |
| ------------------- | ------------- | ---------- | -- | ---- |
| 1 through 8         | .007          | 446.493    | 72 | .000 |
| ------------------- | ------------- | ---------- | -- | ---- |
| 2 through 8         | .116          | 193.853    | 56 | .000 |
| ------------------- | ------------- | ---------- | -- | ---- |
| 3 through 8         | .413          | 79.479     | 42 | .000 |
| ------------------- | ------------- | ---------- | -- | ---- |
| 4 through 8         | .626          | 42.155     | 30 | .069 |
| ------------------- | ------------- | ---------- | -- | ---- |
| 5 through 8         | .792          | 20.980     | 20 | .398 |
| ------------------- | ------------- | ---------- | -- | ---- |
| 6 through 8         | .903          | 9.204      | 12 | .685 |
| ------------------- | ------------- | ---------- | -- | ---- |
| 7 through 8         | .965          | 3.160      | 6  | .789 |
| ------------------- | ------------- | ---------- | -- | ---- |
| 8                   | .998          | .171       | 2  | .918 |
| ------------------- | ------------- | ---------- | -- | ---- |

standardized canonical discriminant function coefficients

| ------ | ---------------------------------------------------------------- |
|        | function                                                         |
|        | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
|        | 1     | 2     | 3     | 4      | 5     | 6      | 7     | 8      |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
| int1   | .141  | .231  | -.164 | .538   | .374  | .285   | -.553 | -.525  |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
| int2   | -.091 | -.026 | 1.162 | .362   | .173  | -.229  | .113  | -.056  |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
| int3   | .443  | .271  | -.120 | 1.320  | -.256 | .975   | .506  | .233   |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
| int4   | .461  | 1.054 | .513  | .623   | -.160 | 1.670  | -.090 | .638   |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
| int5   | .172  | .651  | .010  | .790   | .127  | -.035  | -.024 | .847   |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
| int6   | .080  | .818  | -.154 | .017   | .417  | .384   | .645  | -.088  |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
| minint | 1.006 | -.471 | -.527 | -.483  | -.071 | -.013  | -.094 | .079   |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |
| maxint | -.699 | -.552 | -.271 | -1.367 | -.589 | -2.077 | -.176 | -1.061 |
| ------ | ----- | ----- | ----- | ------ | ----- | ------ | ----- | ------ |

structure matrix
(last two functions cut off for e-mail line length ;-)

| ------- | -----------------------------------------------------------
|         | function
|         | ------- | ------- | ------- | ----- | -------- | -------- |
|         | 1       | 2       | 3       | 4     | 5        | 6        |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| minint  | .961(*) | -.005   | .078    | -.159 | .010     | -.205    |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| time(a) | .447    | .634(*) | .091    | .246  | -.441    | -.213    |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| int2    | .480    | -.031   | .752(*) | .119  | .164     | -.277    |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| maxint  | .232    | .489    | .050    | .014  | -.689(*) | -.328    |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| int4    | .187    | .515    | .271    | -.272 | -.633(*) | .196     |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| int3    | .161    | -.096   | -.128   | .520  | -.611(*) | -.044    |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| int5    | .201    | .444    | -.137   | .274  | .035     | -.599(*) |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| int6    | .210    | .499    | -.065   | -.207 | .448     | -.090    |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |
| int1    | .213    | .230    | -.107   | .313  | .316     | -.069    |
| ------- | ------- | ------- | ------- | ----- | -------- | -------- |

pooled within-groups correlations between discriminating variables and
standardized canonical discriminant functions variables ordered by
absolute size of correlation within function.
* largest absolute correlation between each variable and any
* discriminant function
a this variable not used in the analysis.
=========================================================================

--
Christoph Lange                                    clange at epost.de
Verhaltensbiologie, FU Berlin                            838-55068