predict.specproc_rsimca: Predictions of a Robust SIMCA Model

View source: R/rsimca.R

predict.specproc_rsimcaR Documentation

Predictions of a Robust SIMCA Model

Description

Predicts the classes of new observations with a model fitted by rsimca(), or their distances to the classes.

Usage

## S3 method for class 'specproc_rsimca'
predict(object, newdata, type = c("class", "distances"), ...)

Arguments

object

An object returned by rsimca().

newdata

A numeric matrix or data frame with the same variables as the training data.

type

"class" (default) for the predicted classes, or "distances" for the combined distances to the classes.

...

Not used.

Value

With type = "class", a factor of the predicted classes. With type = "distances", a tibble with the combined distance of each observation to each class (one column per class), and outlying, TRUE for the observations outlying for every class.

Author(s)

Christian L. Goueguel

See Also

rsimca()

Examples

# iris: train on 100 flowers, predict the 50 others
set.seed(1)
train <- sample(nrow(iris), 100)
fit <- rsimca(iris[train, 1:4], iris$Species[train], ncomp = 2)
head(predict(fit, iris[-train, 1:4]))
head(predict(fit, iris[-train, 1:4], type = "distances"))

specProc documentation built on Nov. 20, 2026, 5:11 p.m.