predict.specproc_rsimpls: Predictions of a Robust PLS Model

View source: R/rsimpls.R

predict.specproc_rsimplsR Documentation

Predictions of a Robust PLS Model

Description

Predicts the responses of new observations with a model fitted by rsimpls(), or computes their scores.

Usage

## S3 method for class 'specproc_rsimpls'
predict(object, newdata, type = c("response", "scores"), ncomp = NULL, ...)

Arguments

object

An object returned by rsimpls().

newdata

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

type

"response" (default) for the predicted responses, or "scores" for the scores and their score and orthogonal distances.

ncomp

With type = "response", the number of components of the predictions, from 1 to the ncomp_max of the model. Default is the ncomp of the model. The models with fewer or more components come from the same ROBPCA fit (see rsimpls()).

...

Not used.

Value

With type = "response", a numeric vector of predictions (one response) or a matrix with one column per response. With type = "scores", a tibble with the scores (Comp1, ...), the score distance sd and the orthogonal distance od of each observation.

Author(s)

Christian L. Goueguel

See Also

rsimpls()

Examples

data(forageLIBS)
wl <- suppressWarnings(as.numeric(names(forageLIBS)))
spectra <- forageLIBS[which(wl > 380 & wl < 430)]
set.seed(1)
fit <- rsimpls(spectra[1:300, ], forageLIBS$Ca[1:300], ncomp = 4)
head(predict(fit, spectra[301:368, ]))
head(predict(fit, spectra[301:368, ], ncomp = 2))
head(predict(fit, spectra[301:368, ], type = "scores"))

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