This function fits a ULDA (Uncorrelated Linear Discriminant Analysis) model to the provided data, with an option for forward selection of variables based on Pillai's trace or Wilks' Lambda. It can also handle missing values, perform downsampling, and compute the linear discriminant scores and group means for classification. The function returns a fitted ULDA model object.
folda(
datX,
response,
subsetMethod = c("forward", "all"),
testStat = c("Pillai", "Wilks"),
correction = TRUE,
alpha = 0.1,
prior = NULL,
misClassCost = NULL,
missingMethod = c("medianFlag", "newLevel"),
downSampling = FALSE,
kSample = NULL
)
A list of class ULDA
containing the following components:
The matrix of scaling coefficients for the linear discriminants.
The group means of the linear discriminant scores.
The prior probabilities for each class.
The misclassification cost matrix.
A reference for handling missing values.
The terms used in the model formula.
The levels of the factors used in the model.
The indices of the selected variables.
The standard deviations of the selected variables.
The means of the selected variables.
The Pillai's trace statistic.
The p-value associated with Pillai's trace.
The Gini index of the predictions on the training data.
The confusion matrix for the training data predictions.
Information about the forward selection process, if applicable.
A message indicating why forward selection stopped, if applicable.
A data frame containing the predictor variables.
A factor representing the response variable with multiple classes.
A character string specifying the method for variable
selection. Options are "forward"
for forward selection or "all"
for
using all variables. Default is "forward"
.
A character string specifying the test statistic to use for
forward selection. Options are "Pillai"
or "Wilks"
. Default is
"Pillai"
.
A logical value indicating whether to apply a multiple
comparison correction during forward selection. Default is TRUE
.
A numeric value between 0 and 1 specifying the significance level for the test statistic during forward selection. Default is 0.1.
A numeric vector representing the prior probabilities for each
class in the response variable. If NULL
, the observed class frequencies
are used as the prior. Default is NULL
.
A square matrix \(C\), where each element \(C_{ij}\)
represents the cost of classifying an observation into class \(i\) given
that it truly belongs to class \(j\). If NULL
, a default matrix with
equal misclassification costs for all class pairs is used. Default is
NULL
.
A character vector of length 2 specifying how to handle
missing values for numerical and categorical variables, respectively.
Default is c("medianFlag", "newLevel")
.
A logical value indicating whether to perform
downsampling to balance the class distribution in the training data or
speed up the program. Default is FALSE
.
An integer specifying the maximum number of samples to take
from each class during downsampling. If NULL
, the number of samples is
limited to the size of the smallest class. Default is NULL
.
Howland, P., Jeon, M., & Park, H. (2003). Structure preserving dimension reduction for clustered text data based on the generalized singular value decomposition. SIAM Journal on Matrix Analysis and Applications
Wang, S. (2024). A New Forward Discriminant Analysis Framework Based On Pillai's Trace and ULDA. arXiv preprint arXiv:2409.03136. Available at https://arxiv.org/abs/2409.03136.
# Fit the ULDA model
fit <- folda(datX = iris[, -5], response = iris[, 5], subsetMethod = "all")
# Fit the ULDA model with forward selection
fit <- folda(datX = iris[, -5], response = iris[, 5], subsetMethod = "forward")
Run the code above in your browser using DataLab