eigen2 | R Documentation |
Solves the generalized eigenvalue problem (B - lambda*W)*alpha = 0, where B and W are symmetric matrices of the same size, W is positive definite, lambda is a scalar and alpha and 0 are vectors.
eigen2(B, W)
B, W |
Similarly sized symmetric matrices with W positive definite. |
If W is not specified, W = I is assumed.
A list with components values
and vectors
as for eigen
X <- as.matrix(subset(iris, select = -Species)) W <- crossprod(resid(aov(X ~ Species, iris))) B <- crossprod(resid(aov(X ~ 1, iris))) - W n <- nrow(iris) p <- length(levels(iris$Species)) (ev <- eigen2(B/(p - 1), W/(n - p))) ## hand-made discriminant analysis DF <- X %*% ev$vectors[, 1:2] with(iris, { plot(DF, col = Species, pch = 20, xlab = expression(DF[1]), ylab = expression(DF[2])) legend("topleft", levels(Species), pch = 20, col = 1:3) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.