reLDA {Momocs} | R Documentation |
"Redo" a LDA on new data
Description
Basically a wrapper around predict.lda from the package MASS. Uses a LDA model to classify new data.
Usage
reLDA(newdata, LDA)
## Default S3 method:
reLDA(newdata, LDA)
## S3 method for class 'PCA'
reLDA(newdata, LDA)
## S3 method for class 'Coe'
reLDA(newdata, LDA)
Arguments
newdata |
|
LDA |
a LDA object |
Value
a list with components (from ?predict.lda ).
class factor of classification
posterior posterior probabilities for the classes
x the scores of test cases
res data.frame of the results
CV.tab a confusion matrix of the results
CV.correct proportion of the diagonal of CV.tab
newdata the data used to calculate passed to predict.lda
Note
Uses the same number of PC axis as the LDA object provided. You should probably use rePCA in conjunction with reLDA to get 'homologous' scores.
Examples
# We select the first 10 individuals in bot,
# for whisky and beer bottles. It will be our referential.
bot1 <- slice(bot, c(1:10, 21:30))
# Same thing for the other 10 individuals.
# It will be our unknown dataset on which we want
# to calculate classes.
bot2 <- slice(bot, c(11:20, 31:40))
# We calculate efourier on these two datasets
bot1.f <- efourier(bot1, 8)
bot2.f <- efourier(bot2, 8)
# Here we obtain our LDA model: first, a PCA, then a LDA
bot1.p <- PCA(bot1.f)
bot1.l <- LDA(bot1.p, "type")
# we redo the same PCA since we worked with scores
bot2.p <- rePCA(bot1.p, bot2.f)
# we finally "predict" with the model obtained before
bot2.l <- reLDA(bot2.p, bot1.l)
bot2.l
[Package Momocs version 1.4.1 Index]