| predict.specproc_opls | R Documentation |
Applies an OPLS model fitted by opls() to new data: removes the
orthogonal components (the OPLS filter), or predicts the response or the
scores.
## S3 method for class 'specproc_opls'
predict(object, newdata, type = c("correction", "response", "scores"), ...)
object |
A model returned by |
newdata |
A numeric matrix or data frame of new data, with the same
variables as the calibration data. If both have column names, the
columns of |
type |
The prediction: |
... |
Not used. |
The new data are preprocessed with the centers and scales of the
calibration data, and the orthogonal components are removed one at a time
(\textbf{t}_o = \textbf{X}\textbf{w}_o,
\textbf{X} \leftarrow \textbf{X} - \textbf{t}_o\textbf{p}_o^T).
The predicted response is \textbf{X}\textbf{w}c, of the filtered
data, back in the units of y.
A tibble of filtered data or of scores, or a numeric vector of predicted responses.
opls(), step_opls()
data(forageLIBS)
wl <- suppressWarnings(as.numeric(names(forageLIBS)))
spectra <- forageLIBS[which(wl > 760 & wl < 780)] # the K I resonance lines
cal <- 1:300
fit <- opls(spectra[cal, ], forageLIBS$K[cal], ncomp = 2)
head(predict(fit, spectra[-cal, ], type = "response"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.