shrinkage_da | R Documentation |
This function provides a shrinkage-based discriminant analysis using the
sda
routine from the corpcor package.
The method can regularize (shrink) the discriminant directions for
high-dimensional data, potentially improving robustness and reducing overfitting.
shrinkage_da(
X,
Y,
preproc = center(),
lambda,
lambda.var,
lambda.freqs,
diagonal = FALSE,
verbose = FALSE
)
X |
A numeric matrix of size |
Y |
A factor or numeric vector of length |
preproc |
A pre-processing function or object from multivarious
(e.g. |
lambda |
Regularization parameter for the |
lambda.var |
Regularization parameter for the variance (covariance) terms,
passed to |
lambda.freqs |
Regularization parameter for class frequency shrinkage,
passed to |
diagonal |
Logical, if |
verbose |
Logical, if |
Internally, the function:
Preprocesses X
using preproc
.
Calls sda
with the specified lambda
, lambda.var
, lambda.freqs
, etc.
Extracts ret\$beta
(the discriminant directions) and ret\$alpha
(the intercept).
Projects the preprocessed data to obtain the score matrix s
.
Constructs a discriminant_projector
object with class "shrinkda"
.
A discriminant_projector
object (subclass "shrinkda"
) containing:
v
: A d \times m
matrix of discriminant directions
(ret\$beta
transposed).
s
: An n \times m
matrix of projected scores (the original data
in the shrinkage discriminant space).
sdev
: Standard deviations of each column in s
.
labels
: The class labels (in character form).
alpha
: Intercept or offset term from sda
result (if any).
preproc
: The pre-processing object used.
classes
: Includes the string "shrinkda"
.
sda
, discriminant_projector
## Not run:
library(multivarious)
data(iris)
X <- as.matrix(iris[, 1:4])
Y <- iris[, 5]
# Perform shrinkage DA with default centering
res <- shrinkage_da(X, Y, lambda=0.5)
# Inspect the projector
print(res)
# Project new data
# new_data <- ...
# projected_scores <- project(res, new_data)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.