Title: | Transformation Discriminant Analysis |
---|---|
Description: | Performs transformation discrimination analysis and non-transformation discrimination analysis. It also includes functions for Linear Discriminant Analysis, Quadratic Discriminant Analysis, and Mixture Discriminant Analysis. In the context of mixture discriminant analysis, it offers options for both common covariance matrix (common sigma) and individual covariance matrices (uncommon sigma) for the mixture components. |
Authors: | Jing Li [aut, cre], Yana Melnykov [aut] |
Maintainer: | Jing Li <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.0 |
Built: | 2024-11-25 16:50:53 UTC |
Source: | CRAN |
Transformation and mixture discriminant analysis.
Package: | transDA |
Type: | Package |
Version: | 1.0.0 |
Date: | 2024-6-10 |
License: | GPL (>= 2) |
LazyLoad: | no |
Function 'tda'
is the main function of the package that allows running traditional linear and quadratic discriminant procedures as well as more flexible options such as mixture discriminant analysis, transformation discriminant analysis, or their combination.
Function 'predict.tda'
makes classification predictions for a provided testing data set.
Jing Li and Yana Melnykov
Maintainer: Jing Li [email protected]
Hastie, T., & Tibshirani, R. (1996). Discriminant analysis by Gaussian mixtures. Journal of the Royal Statistical Society Series B: Statistical Methodology, 58(1), 155-176.
Yana Melnykov & Jing Li. (2024) Transformation Discriminant Analysis. (under review)
set.seed(123) data(iris) MDA <- tda(x = iris[,1:4], max_k = 2, ID = iris$Species, trans = FALSE) summary(MDA)
set.seed(123) data(iris) MDA <- tda(x = iris[,1:4], max_k = 2, ID = iris$Species, trans = FALSE) summary(MDA)
'tda'
Predicts class memberships for new observations based on the model returned by function 'tda'
.
## S3 method for class 'tda' predict(object, newdata, ...)
## S3 method for class 'tda' predict(object, newdata, ...)
object |
An object of class |
newdata |
A data frame or matrix with data to be classified |
... |
Additional arguments that are passed to or from other methods |
classification |
A factor containing predicted class labels for |
Z |
A matrix of posterior probabilities for observations from |
set.seed(123) split_indices <- sample(nrow(iris), size = round(0.8 * nrow(iris)), replace = FALSE) split_indices <- sort(split_indices) traindata <- iris[split_indices,] testdata <- iris[-split_indices,] MDA <- tda(x = traindata[,1:4], max_k = 2, ID = traindata$Species, trans = FALSE) pred <- predict(MDA, testdata[,-5]); pred
set.seed(123) split_indices <- sample(nrow(iris), size = round(0.8 * nrow(iris)), replace = FALSE) split_indices <- sort(split_indices) traindata <- iris[split_indices,] testdata <- iris[-split_indices,] MDA <- tda(x = traindata[,1:4], max_k = 2, ID = traindata$Species, trans = FALSE) pred <- predict(MDA, testdata[,-5]); pred
'tda'
Summary for the results of discriminant analysis obtained by function 'tda'
## S3 method for class 'tda' summary(object, ...) ## S3 method for class 'summary.tda' print(x, ...)
## S3 method for class 'tda' summary(object, ...) ## S3 method for class 'summary.tda' print(x, ...)
object |
An object of class |
x |
An object of class |
... |
Additional arguments that are passed to or from other methods |
Function 'summary.tda'
calculates and returns a list of summary statistics for the model estimated by function 'tda'
set.seed(123) model <- tda(x = iris[,1:4], max_k = 2, ID = iris$Species, trans = FALSE) summary(model)
set.seed(123) model <- tda(x = iris[,1:4], max_k = 2, ID = iris$Species, trans = FALSE) summary(model)
Implements discriminant analysis methods including traditional linear (LDA), quadratic (QDA), transformation (TDA), mixture (MDA) discriminant analysis, and their combinations such as TQDA or TLMDA. The user chooses a specific method by specifying options for common or varying transformation parameters as well as covariance matrices.
tda(x, max_k, ID, trans = TRUE, common_lambda = FALSE, common_sigma = FALSE, iter = 50, subgroup = NULL, tol= 0.001, lambda0 = 0.015)
tda(x, max_k, ID, trans = TRUE, common_lambda = FALSE, common_sigma = FALSE, iter = 50, subgroup = NULL, tol= 0.001, lambda0 = 0.015)
x |
A frame or matrix containing a training data set |
max_k |
The maximum number of mixture components within each class to be fitted |
ID |
A variable containing class memberships for all observations |
trans |
A transformation indicator: |
common_lambda |
A parameter that regulates transformations. If |
common_sigma |
A homoscedasticity parameter: if |
iter |
A maximum number of iterations of the EM algorithm; the default value is 50 |
subgroup |
A vector containing the number of mixture components per each class to be fitted |
tol |
Tolerance level for a stopping critetion based on the relative difference in two consecutive log-likelihood values |
lambda0 |
Starting value for transformation parameters |
BIC |
Values of the Bayesian Information Criterion calculated for each evaluated model |
subprior |
Estimated component priors for each class |
mu |
Estimated component means for each class |
sigma |
Estimated component covariance matrices for each group |
lambda |
Estimated transformation parameters |
loglik |
The log-likelihood value for the model with the lowest BIC |
pred_ID |
Estimated classification of observations in the training data set |
prior |
Estimated class priors |
misclassification_rate |
Misclassification rate for the training data set |
ARI |
Adjusted Rand index value |
Z |
Matrix of posterior probabilities for the training data set |
set.seed(123) # Example 1: MDA <- tda(x = iris[,1:4], max_k = 2,ID = iris$Species, trans = FALSE) print(MDA) summary(MDA) # Example 2: LDA <- tda(x = iris[,1:4], max_k = 1, ID = iris$Species, trans = FALSE, common_sigma = TRUE) print(LDA) summary(LDA) # Example 3: QDA <- tda(x = iris[,1:4], subgroup = c(1, 1, 1), ID = iris$Species, trans = FALSE, common_sigma = FALSE) print(QDA) summary(QDA) # Example 4: TQDA <- tda(x = iris[,1:4], subgroup = c(1, 1, 1), ID = iris$Species, trans = TRUE, common_sigma = FALSE, common_lambda = TRUE) print(TQDA) summary(TQDA)
set.seed(123) # Example 1: MDA <- tda(x = iris[,1:4], max_k = 2,ID = iris$Species, trans = FALSE) print(MDA) summary(MDA) # Example 2: LDA <- tda(x = iris[,1:4], max_k = 1, ID = iris$Species, trans = FALSE, common_sigma = TRUE) print(LDA) summary(LDA) # Example 3: QDA <- tda(x = iris[,1:4], subgroup = c(1, 1, 1), ID = iris$Species, trans = FALSE, common_sigma = FALSE) print(QDA) summary(QDA) # Example 4: TQDA <- tda(x = iris[,1:4], subgroup = c(1, 1, 1), ID = iris$Species, trans = TRUE, common_sigma = FALSE, common_lambda = TRUE) print(TQDA) summary(TQDA)