Skip to contents

Performs Y-permutation tests to assess the robustness of OPLS models by comparing model performance statistics on real vs. permuted response labels.

Usage

opls_perm(smod, n = 10, plot = TRUE, mc = FALSE)

Arguments

smod

An OPLS model object of class OPLS_metabom8.

n

Integer. Number of permutations to perform.

plot

Logical. If TRUE, generates a visual summary of permutation statistics.

mc

Logical. If TRUE, enables multicore processing (currently not implemented).

Value

A data.frame with model metrics (e.g., R2, Q2, AUROC) from both permuted and original models.

Details

Each permutation shuffles the response labels and fits a new OPLS model. The function captures model statistics (R2, Q2, AUC) to compare against the non-permuted model. This helps determine whether the original model performance is better than expected by chance.

References

Wiklund, S. et al. (2008). A Tool for Improved Validation of OPLS Models. Journal of Chemometrics, 22(11–12), 594–600.

Examples

data(covid)
X <- covid$X
an <- covid$an

model <- opls(X, Y = an$type)
#> Performing discriminant analysis.
#> Reducing k to 5 due to small group size (min n = 5).
#> An O-PLS-DA model with 1 predictive and 1 orthogonal components was fitted.

perm_results <- opls_perm(model, n = 10)
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.
#> Warning: Deprecated use a matrix as predictor. Unexpected results may be produced, please pass a numeric vector.