View source: R/projected_osc.R
| projected_osc | R Documentation |
The projected orthogonal signal correction (POSC) method is a preprocessing technique used to remove systematic variation from predictor variables that is orthogonal to the response variable. This function implements the POSC algorithm for model fitting and prediction.
projected_osc(
x,
y,
ncomp = 4,
center = TRUE,
scale = FALSE,
tol = 1e-10,
newdata = NULL
)
x |
A matrix or data frame of the predictor variables. |
y |
A vector of the response variable. |
ncomp |
An integer specifying the number of orthogonal components removed (at least 1), as in the other orthogonalization methods. The underlying PLS model has |
center |
A logical value indicating whether to mean-center |
scale |
A logical value indicating whether to scale |
tol |
A numeric value; orthogonal components whose singular value is smaller than |
newdata |
An optional matrix or data frame of new predictor variables to be corrected using the POSC model. It is preprocessed with the centers and scales of |
POSC obtains OPLS-filtered data directly from an ordinary (non-orthogonalized) PLS1 model (Kemsley and Tapp, 2009):
A PLS1 model with ncomp + 1 components is fitted, giving the score matrix
\textbf{T} and the fitted response \hat{\textbf{y}}.
The part of the score space orthogonal to \hat{\textbf{y}},
\textbf{T} - \hat{\textbf{y}}(\hat{\textbf{y}}^T\hat{\textbf{y}})^{-1}\hat{\textbf{y}}^T\textbf{T},
spans ncomp orthogonal components with scores \textbf{T}_o.
The orthogonal loadings are \textbf{P}_o = \textbf{X}^T\textbf{T}_o(\textbf{T}_o^T\textbf{T}_o)^{-1}
and the filtered data are \textbf{X} - \textbf{T}_o\textbf{P}_o^T.
The filtered data are identical to those obtained from an OPLS model with one
predictive and ncomp orthogonal components (opls() with the same
ncomp).
An object of class specproc_projected_osc (a list), which predict() applies to new spectra, with the following components:
correction: The corrected x.
scores: The orthogonal scores matrix \textbf{T}_o.
loadings: The orthogonal loadings matrix \textbf{P}_o.
weights: The orthogonal weights \textbf{W}_o, such that \textbf{T}_o = \textbf{XW}_o.
center, scale: The column centers and scales applied to x.
newdata: If newdata is provided, a list with the corrected new data (correction) and its orthogonal scores (scores).
Christian L. Goueguel
Kemsley, E.K., Tapp, H.S., (2009). OPLS filtered data can be obtained directly from non-orthogonalized PLS1. Journal of Chemometrics, 23(5):263-264.
Trygg, J., Wold, S., (2002). Orthogonal projections to latent structures (O-PLS). Journal of Chemometrics, 16(3):119-128.
predict.specproc_filter() to correct new spectra with the fitted filter, and
step_projected_osc() to use it in a tidymodels recipe.
data(forageLIBS)
spectra <- forageLIBS[-(1:14)] # the spectral channels
cal <- 1:300
res <- projected_osc(spectra[cal, ], forageLIBS$K[cal], ncomp = 2, newdata = spectra[-cal, ])
dim(res$newdata$correction)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.