# [R] lda output missing

David L Carlson dcarlson at tamu.edu
Thu Dec 8 22:16:12 CET 2011

```The Proportion of trace will only show up if there are two or more linear
discriminant functions. With two groups you have only one function, so the
Proportion of trace is 1.0 for that function.

group1 <- data.frame(Group="G1", Var1=rnorm(50), Var2=rnorm(50))
group2 <- data.frame(Group="G2", Var1=rnorm(50), Var2=rnorm(50))
Groups <- rbind(group1, group2)
lda(Group~Var1+Var2, Groups)            # No Proportion of trace
group3 <- data.frame(Group="G3", Var1=rnorm(50), Var2=rnorm(50))
Groups <- rbind(group1, group2, group3)
lda(Group~Var1+Var2, Groups)            # Now it shows up

For predicted group membership, look at predict.lda
For tests of significance, look at Anova in package car
For canonical discriminant analysis, look at package candisc

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Sarah Goslee
Sent: Thursday, December 08, 2011 11:13 AM
To: David Lutz
Cc: r-help at r-project.org
Subject: Re: [R] lda output missing

That's odd. You don't provide a reproducible example, but using
a built-in dataset (from the help for lda) I get the Proportion of Trace
given by the print.lda method.

library(MASS)
Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp =
rep(c("s","c","v"), rep(50,3)))
train <- sample(1:150, 75)
z <- lda(Sp ~ ., Iris, prior = c(1,1,1)/3, subset = train)
print(z)
Call:
lda(Sp ~ ., data = Iris, prior = c(1, 1, 1)/3, subset = train)

Prior probabilities of groups:
c         s         v
0.3333333 0.3333333 0.3333333

Group means:
Sepal.L. Sepal.W. Petal.L.  Petal.W.
c 5.947826 2.786957 4.326087 1.3652174
s 5.050000 3.380769 1.465385 0.2346154
v 6.811538 3.023077 5.700000 2.0653846

Coefficients of linear discriminants:
LD1       LD2
Sepal.L. -1.6665885  1.104460
Sepal.W. -0.8681909  1.872188
Petal.L.  2.4670375 -1.499070
Petal.W.  4.2156275  2.948759

Proportion of trace:
LD1    LD2
0.9916 0.0084

Here's my sessionInfo(). Are you certain everything is up-to-date?
What OS are you running? Do you have other packages loaded that could
be interfering? What happens when you run the example I used?

> sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: x86_64-redhat-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C                 LC_NAME=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] MASS_7.3-16

loaded via a namespace (and not attached):
[1] tools_2.14.0

On Thu, Dec 8, 2011 at 10:29 AM, David Lutz <lutzda at wfu.edu> wrote:
> Hello everyone,
>
> I am working on a linear discriminant analysis and am having issues
finding
> the full output of my lda. Specifically, there is no reporting of the
> Proportion of Trace that is a normal output of the procedure. I'm using a
> csv file and everything is reading in correctly. I've looked and looked
and
> can't figure out why my output is not complete. Is it something simple
that
> I am overlooking?
>
> I am working in R 2.14.0 with an updated MASS package. Here is my syntax:
>
> lda(CC ~ sumstem + maxdbh + maxh + cdlai + sumlai + sumbas +
>    totalbio + ratio, data = practice)
>
> and the output is:
>
> Prior probabilities of groups:
> normal   warm
>   0.5    0.5
>
> Group means:
>        sumstem   maxdbh     maxh       cdlai   sumlai   sumbas totalbio
> normal 901.3722 16.66994 15.70927 0.010393258 1.672247 5.471812 27.67875
> warm   972.4916 22.27247 19.64740 0.002429775 3.181994 9.892683 47.68511
>            ratio
> normal 0.01162921
> warm   0.85721910
>
> Coefficients of linear discriminants:
>                  LD1
> sumstem   0.001111176
> maxdbh    0.034299258
> maxh     -0.287343783
> cdlai    -2.021350057
> sumlai    1.407215702
> sumbas   -0.419422181
> totalbio  0.110403369
> ratio     0.001657649
>
>
>
--
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help