predict.specproc_domain: Flag Spectra Outside the Applicability Domain

View source: R/applicability_domain.R

predict.specproc_domainR Documentation

Flag Spectra Outside the Applicability Domain

Description

Computes Hotelling's T^2 and the Q residual of new spectra in the PCA model of applicability_domain(), and flags those outside the domain.

Usage

## S3 method for class 'specproc_domain'
predict(object, newdata, ...)

Arguments

object

The result of applicability_domain().

newdata

The new spectra: a numeric matrix or data frame with the variables of the calibration spectra.

...

Not used.

Value

A tibble of class specproc_influence, as returned by q_residuals(), with one row per spectrum: sample, t2 and its limit, q and its limit, outlier ("regular", "extreme" for a high T^2, "residual" for a high Q, or "both"), and inside, whether the spectrum lies inside the domain. Draw it with plot_influence().

See Also

applicability_domain()

Examples

data(forageLIBS)
wl <- suppressWarnings(as.numeric(names(forageLIBS)))
spectra <- as.matrix(forageLIBS[which(wl > 380 & wl < 430)])
domain <- applicability_domain(spectra[1:300, ])
flags <- predict(domain, spectra[301:368, ])
flags[!flags$inside, ]

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