Learn R Programming

valueprhr (version 0.1.0)

extract_pls_importance: Extract PLS Variable Importance

Description

Extracts variable importance scores from a fitted PLS model.

Usage

extract_pls_importance(pls_result, ncomp = NULL)

Value

Data frame with variable names and importance scores.

Arguments

pls_result

Result from fit_pls_multivariate.

ncomp

Number of components to use. Default uses optimal.

Examples

Run this code
# \donttest{
if (requireNamespace("pls", quietly = TRUE)) {
  set.seed(123)
  n <- 50
  p <- 10
  X <- matrix(rnorm(n * p), n, p)
  colnames(X) <- paste0("X", 1:p)
  Y <- X[, 1:3] %*% diag(c(1, 0.5, 0.3)) + matrix(rnorm(n * 3, 0, 0.5), n, 3)
  colnames(Y) <- paste0("Y", 1:3)

  result <- fit_pls_multivariate(X, Y, max_components = 5)
  importance <- extract_pls_importance(result)
  print(head(importance))
}
# }

Run the code above in your browser using DataLab