fda | R Documentation |
Functions fda
and fdasvd
fit a factorial discriminant analysis (FDA). The functions maximize the compromise p'Bp / p'Wp
, i.e. max p'Bp
with constraint p'Wp = 1
. Vectors p
are the linear discrimant coefficients "LD".
Function fda
uses an eigen decomposition of W^(-1)B
(if W
is singular, W^(-1) can be replaced by a pseudo-inverse, with argument pseudo
), and function fdasvd
a weighted SVD decomposition of the matrix of the class centers. See the code for details.
fda(Xr, Yr, Xu = NULL, ncomp = NULL, pseudo = FALSE)
fdasvd(Xr, Yr, Xu = NULL, ncomp = NULL, ...)
Xr |
A |
Yr |
A vector of length |
Xu |
A |
ncomp |
The maximum number of components to consider ( |
pseudo |
For function |
... |
For function |
A list of outputs (see examples), such as:
Tr |
The Xr-score matrix ( |
Tu |
The Xu-score matrix ( |
Tcenters |
The Xr-class centers score matrix ( |
P |
The Xr-loadings matrix ( |
explvar |
Proportions of explained variance by PCA of the class centers in transformed scale. |
And other outputs ("z" outputs relate on transformed data; see the code).
Saporta G., 2011. ProbabilitÃ©s analyse des donnÃ©es et statistique. Editions Technip, Paris, France.
data(iris)
Xr <- iris[, 1:4]
yr <- iris[, 5]
fm <- fda(Xr, yr)
names(fm)
# Xr-scores
headm(fm$Tr)
# Xr-class centers scores
fm$Tcenters
# Xr-loadings matrix
# = coefficients of linear discriminants
# = "LD" of function lda of MASS package
fm$P
# Explained variance by PCA of the class centers
# in transformed scale
fm$explvar
plotxy(fm$Tr, group = yr, ellipse = TRUE)
points(fm$Tc, pch = 8, col = "blue")
# Object Tcenters is the projection of the class centers in the score space
fm <- fda(Xr, yr)
fm$Tcenters
centers <- centr(Xr, yr)$centers
centers
fm <- fda(Xr, yr, centers)
fm$Tu
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.