Learn R Programming

Momocs (version 1.1.6)

LDA: Linear Discriminant Analysis on Coe objects

Description

Performs a LDA on Coe objects. Relies on lda in MASS.

Usage

LDA(x, fac, retain, ...)

# S3 method for default LDA(x, fac, retain, ...)

# S3 method for PCA LDA(x, fac, retain = 0.99, verbose = TRUE, ...)

Arguments

x
a PCA object
fac
the grouping factor (names of one of the $fac column or column id)
retain
the proportion of the total variance to retain (if retain<1) using scree, or the number of PC axis (if retain>1).
...
additional arguments to feed lda
verbose
logical whether to print messages

Value

a 'LDA' object on which to apply plot.LDA, which is a list with components:
  • x any Coe object (or a matrix)
  • fac grouping factor used
  • removed ids of columns in the original matrix that have been removed since constant (if any)
  • mod the raw lda mod from lda
  • mod.pred the predicted model using x and mod
  • CV.fac cross-validated classification
  • CV.tab cross-validation tabke
  • CV.correct proportion of correctly classified individuals
  • CV.ce class error
  • LDs unstandardized LD scores see Claude (2008)
  • mshape mean values of coefficients in the original matrix
  • method inherited from the Coe object (if any)

See Also

Other multivariate: CLUST, KMEANS, MANOVA_PW, MANOVA, PCA

Examples

Run this code
data(bot)
bot.f <- efourier(bot, 24)
bot.p <- PCA(bot.f)
LDA(bot.p, 'type', retain=0.99) # retains 0.99 of the total variance
LDA(bot.p, 'type', retain=5) # retain 5 axis
bot.l <- LDA(bot.p, 'type', retain=0.99)
bot.l
plot(bot.l)
bot.f$fac$plop <- factor(rep(letters[1:4], each=10))
bot.l <- LDA(PCA(bot.f), 'plop')
bot.l
plot(bot.l)

Run the code above in your browser using DataLab