candisc
performs a generalized canonical discriminant analysis for
one term in a multivariate linear model (i.e., an mlm
object),
computing canonical scores and vectors. It represents a transformation
of the original variables into a canonical space of maximal differences
for the term, controlling for other model terms.
To be of any use,
the term should be a factor or interaction corresponding to a
multivariate test with 2 or more degrees of freedom for the
null hypothesis.candisc(mod, ...)
## S3 method for class 'mlm':
candisc(mod, term, type = "2", manova, ndim = rank, ...)
## S3 method for class 'candisc':
coef(object, type = c("std", "raw", "structure"), ...)
## S3 method for class 'candisc':
plot(x, which = 1:2, conf = 0.95, col, pch, scale, asp = 1,
var.col = "blue", var.lwd = par("lwd"), prefix = "Can", suffix=TRUE,
titles.1d = c("Canonical scores", "Structure"), ...)
## S3 method for class 'candisc':
print(x, digits=max(getOption("digits") - 2, 3), ...)
## S3 method for class 'candisc':
summary(object, means = TRUE, scores = FALSE, coef = c("std"),
ndim, digits = max(getOption("digits") - 2, 4), ...)
mod
term
, one of: "II", "III", "2", or "3"Anova.mlm
object corresponding to mod
. Normally,
this is computed internally by Anova(mod)
summary
method)
the means
, structure
, scores
and
coeffs.*
components. The default is the rank of the H matrix for the hypplot
methodplot
method.
In this version, you should assign colors and point symbols explicitly, rather than relying on
the somewhat arbitrary defaults.plot
methodplot
method. The asp=1
(the default) assures that
the units on the horizontal and vertical axes are the same, so that lengths and angles of the
variable vectors are interpretable.suffix=TRUE
the percent of hypothesis (H) variance accounted for by each canonical dimension is added to the axis label.type="n"
can be used with
the plot
method to suppress the display of canonical scores.candisc
with the following components:term
mlm
canrsq
of their total.means
, structure
and coeffs.*
componentsterm
term
mlm
objectndim
dimensions, i.e.,
the correlations between the original variates and the canonical scores.
These are sometimes referred to as Total Structure Coefficients.mlm
model and the
canonical scores on ndim
dimensions.
These are calculated as Y %*% coeffs.raw
, where Y
contains the
standardized response variables.dfh
= min( g-1, p) such canonical dimensions, and tests, initally stated
by Bartlett (1938) allow one to determine the number of significant
canonical dimensions. Computational details for the one-way case are described
in Cooley & Lohnes (1971), and in the SAS/STAT User's Guide, "The CANDISC procedure:
Computational Details," mlm
produces
a rank $df_h$ H matrix sum of squares and crossproducts matrix that is
tested against the rank $df_e$ E matrix by the standard multivariate
tests (Wilks' Lambda, Hotelling-Lawley trace, Pillai trace, Roy's maximum root
test). For any given term in the mlm
, the generalized canonical discriminant
analysis amounts to a standard discriminant analysis based on the H matrix for that
term in relation to the full-model E matrix.candiscList
, heplot
, heplot3d
grass.mod <- lm(cbind(N1,N9,N27,N81,N243) ~ Block + Species, data=Grass)
Anova(grass.mod,test="Wilks")
grass.can1 <-candisc(grass.mod, term="Species")
plot(grass.can1, type="n")
# library(heplots)
heplot(grass.can1, scale=6)
# iris data
iris.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, Sepal.Width) ~ Species, data=iris)
iris.can <- candisc(iris.mod, data=iris)
#-- assign colors and symbols corresponding to species
col <- rep(c("red", "black", "blue"), each=50)
pch <- rep(1:3, each=50)
plot(iris.can, col=col, pch=pch)
heplot(iris.can)
# 1-dim plot
iris.can1 <- candisc(iris.mod, data=iris, ndim=1)
plot(iris.can1)
Run the code above in your browser using DataLab