predict.specproc_rpcr: Predictions of a Robust PCR Model

View source: R/rpcr.R

predict.specproc_rpcrR Documentation

Predictions of a Robust PCR Model

Description

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

Usage

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

Arguments

object

An object returned by rpcr().

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 use the same robust PCA (see rpcr()).

...

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

rpcr()

Examples

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

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