Skip to content
Prev 279810 / 398506 Next

lda output missing

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?
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
 [9] LC_ADDRESS=C               LC_TELEPHONE=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:
finding
and
that