Learn R Programming

Rdimtools (version 0.3.2)

do.rlda: Regularized Linear Discriminant Analysis

Description

In small sample case, Linear Discriminant Analysis (LDA) may suffer from rank deficiency issue. Applied mathematics has used Tikhonov regularization - also known as \(\ell_2\) regularization/shrinkage - to adjust linear operator. Regularized Linear Discriminant Analysis (RLDA) adopts such idea to stabilize eigendecomposition in LDA formulation.

Usage

do.rlda(X, label, ndim = 2, alpha = 1)

Arguments

X

an \((n\times p)\) matrix or data frame whose rows are observations and columns represent independent variables.

label

a length-\(n\) vector of data class labels.

ndim

an integer-valued target dimension.

alpha

Tikhonow regularization parameter.

Value

a named list containing

Y

an \((n\times ndim)\) matrix whose rows are embedded observations.

trfinfo

a list containing information for out-of-sample prediction.

projection

a \((p\times ndim)\) whose columns are basis for projection.

References

friedman_regularized_1989Rdimtools

Examples

Run this code
# NOT RUN {
## generate data of 3 types with clear difference
dt1  = aux.gensamples(n=33)-100
dt2  = aux.gensamples(n=33)
dt3  = aux.gensamples(n=33)+100

## merge the data and create a label correspondingly
Y      = rbind(dt1,dt2,dt3)
label  = c(rep(1,33), rep(2,33), rep(3,33))

## try different regularization parameters
out1 <- do.rlda(Y, label, alpha=0.1)
out2 <- do.rlda(Y, label, alpha=1)
out3 <- do.rlda(Y, label, alpha=10)

## visualize
par(mfrow=c(1,3))
plot(out1$Y[,1], out1$Y[,2], main="alpha=0.1")
plot(out2$Y[,1], out2$Y[,2], main="alpha=1")
plot(out3$Y[,1], out3$Y[,2], main="alpha=10")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab