This function implements the modified orthogonal projections to latent structures (O2PLS) algorithm as proposed by Trygg (2002). The OPLS and O2PLS methods differ as follows: OPLS is unidirectional \((X \Rightarrow Y)\), meaning that only orthogonal variations in the \(X\)-space are filtered out. Whilst O2PLS is bi-directional \((X \Leftrightarrow Y)\), meaning that orthogonal variations in both the \(X\)- and \(Y\)-space are filtered out.
Arguments
- x
A numeric matrix or data frame representing the predictor variables.
- y
A numeric vector, matrix or data frame representing the response variables.
- ncomp
An integer giving the number of joint (predictive) components. Default is 1.
- nx
An integer giving the number of \(Y\)-orthogonal components removed from
x. Default is 1.- ny
An integer giving the number of \(X\)-orthogonal components removed from
y. Default is 0.- center
A logical value indicating whether to mean-centered
xandy. Default isTRUE.- scale
A logical value indicating whether to scale
xandy. Default isFALSE.
Value
An object of class o2pls, a list containing:
correction: The filteredx(\(Y\)-orthogonal variation removed).correction_y: The filteredy(\(X\)-orthogonal variation removed).scores: A list with the joint scoresx(\(\textbf{T}\)) andy(\(\textbf{U}\)), and the orthogonal scoresx_orthoandy_ortho.loadings: A list with the joint loadingsxandy, and the orthogonal loadingsx_orthoandy_ortho.weights: A list with the joint weightsx(\(\textbf{W}\)) andy(\(\textbf{C}\)), and the orthogonal weightsx_orthoandy_ortho.center,scale: The column centers and scales applied tox.
Details
The O2PLS method handles situations where systematic \(X\)-orthogonal variation in \(Y\) exists, and it is predictive in both ways, \((X \Rightarrow Y)\) and \((Y \Rightarrow X)\). The systematic part in \(X\) and \(Y\) is divided into two parts, one which is related to both \(X\) and \(Y\) (joint/covarying) and one that is not (orthogonal).
The algorithm follows Trygg and Wold (2003):
The joint weights \(\textbf{W}\) and \(\textbf{C}\) are the dominant singular vectors of \(\textbf{Y}^T\textbf{X}\).
For each \(Y\)-orthogonal component of \(X\), the weight \(\textbf{w}_{o}\) is the dominant singular vector of \(\textbf{E}_{XY}^T\textbf{T}\) (with \(\textbf{T} = \textbf{XW}\) and \(\textbf{E}_{XY} = \textbf{X} - \textbf{TW}^T\)), and \(\textbf{X}\) is deflated by \(\textbf{t}_o\textbf{p}_o^T\).
The same procedure is applied to \(Y\) for the \(X\)-orthogonal components.
The joint components are recomputed from the filtered data.
For a single response variable, ny must be 0 and the method is equivalent
to OPLS with nx orthogonal components.
References
Trygg, J., (2002). O2-PLS for qualitative and quantitative analysis in multivariate calibration. J. Chemom. 16(1):283–293.
Trygg, J., Wold, S., (2003). O2-PLS, a two-block (X–Y) latent variable regression (LVR) method with an integral OSC filter. J. Chemom. 17(1):53–64.
See also
predict.specproc_filter() to correct new spectra with the fitted filter, and
step_o2pls() to use it in a tidymodels recipe, with one or several
outcomes.
Examples
data(forageLIBS)
spectra <- forageLIBS[-(1:14)] # the spectral channels
# potassium and calcium at once
fit <- o2pls(spectra, forageLIBS[c("K", "Ca")], ncomp = 2, nx = 2)
fit
#> An object of class 'o2pls'
#>
#> Joint components: 2
#> X-orthogonal components: 2
#> Y-orthogonal components: 0
#>
#> - correction: 368 x 7152
#> - X weights: 7152 x 2
#> - Y weights: 2 x 2
#> - X scores: 368 x 2
#> - X ortho: 368 x 2
