LDA: Linear Discriminant Analysis on Coe objects

View source: R/mult-LDA.R

LDAR Documentation

Linear Discriminant Analysis on Coe objects

Description

Calculates a LDA on Coe on top of MASS::lda.

Usage

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

## Default S3 method:
LDA(x, fac, retain, ...)

## S3 method for class 'PCA'
LDA(x, fac, retain = 0.99, ...)

Arguments

x

a Coe or 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

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)

Note

For LDA.PCA, retain can be passed as a vector (eg: 1:5, and retain=1, retain=2, ..., retain=5) will be tried, or as "best" (same as before but retain=1:number_of_pc_axes is used).

Silent message and progress bars (if any) with options("verbose"=FALSE).

See Also

Other multivariate: CLUST(), KMEANS(), KMEDOIDS(), MANOVA_PW(), MANOVA(), MDS(), MSHAPES(), NMDS(), PCA(), classification_metrics()

Examples

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)
plot_LDA(bot.l)
bot.f <- mutate(bot.f, plop=factor(rep(letters[1:4], each=10)))
bot.l <- LDA(PCA(bot.f), 'plop')
plot_LDA(bot.l) # will replace the former soon

vbonhomme/Momocs documentation built on Nov. 13, 2023, 8:54 p.m.