Description Usage Arguments Details Value Author(s) References See Also Examples
Performs sparse linear discriminant analysis for mixture of gaussians models.
1 2 3 4 5 6 |
x |
A matrix of the training data with observations down the rows and variables in the columns. |
y |
A matrix initializing the dummy variables representing the groups. |
Z |
Am optional matrix initializing the probabilities representing the groups. |
Rj |
K length vector containing the number of subclasses in each of the K classes. |
lambda |
The weight on the L2-norm for elastic net regression. Default: 1e-6. |
stop |
If STOP is negative, its absolute value corresponds to the desired number of variables. If STOP is positive, it corresponds to an upper bound on the L1-norm of the b coefficients. There is a one to one correspondence between stop and t. |
maxIte |
Maximum number of iterations. Default: 50. |
Q |
The number of components to include. Maximum and default is R-1 (total number of subclasses less one). |
trace |
If TRUE, prints out its progress. Default: FALSE. |
tol |
Tolerance for the stopping criterion (change in RSS). Default: 1e-4 |
... |
additional arguments |
The function finds sparse directions for linear classification of mixture og gaussians models.
Returns a list with the following attributes:
call |
The call |
beta |
The loadings of the sparse discriminative directions. |
theta |
The optimal scores. |
Z |
Updated subclass probabilities. |
Rj |
a vector of the number of ssubclasses per class |
rss |
A vector of the Residual Sum of Squares at each iteration. |
Line Clemmensen
Clemmensen, L., Hastie, T., Witten, D. and Ersboell, K. (2007) "Sparse discriminant analysis", Technometrics, To appear.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # load data
data(penicilliumYES)
X <- penicilliumYES$X
Y <- penicilliumYES$Y
Z <- penicilliumYES$Z
## test samples
Iout <- c(3, 6, 9, 12)
Iout <- c(Iout, Iout+12, Iout+24)
## training data
Xtr <- X[-Iout,]
k <- 3
n <- dim(Xtr)[1]
Rj <- rep(4, 3)
## Normalize data
Xc <- normalize(Xtr)
Xn <- Xc$Xc
p <- dim(Xn)[2]
## perform SMDA with one non-zero loading for each discriminative
## direction
## Not run:
smdaFit <- smda(x = Xn,
y = Y,
Z = Z,
Rj = Rj,
lambda = 1e-6,
stop = -5,
maxIte = 10,
tol = 1e-2)
# testing
Xtst <- X[Iout,]
Xtst <- normalizetest(Xtst, Xc)
test <- predict(smdaFit, Xtst)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.