Title: | A New Reduced-Rank Linear Discriminant Analysis Method |
---|---|
Description: | A new reduced-rank LDA method which works for high dimensional multi-class data. |
Authors: | Yue S. Niu, Ning Hao, and Bin Dong |
Maintainer: | Ning Hao <[email protected]> |
License: | GPL-2 |
Version: | 1.0 |
Built: | 2024-12-14 06:31:31 UTC |
Source: | CRAN |
A new reduced-rank LDA method which works for high dimensional multi-class data.
Package: | SPCALDA |
Type: | Package |
Version: | 1.0 |
Date: | 2015-11-04 |
License: | GPL-2 |
Yue S. Niu, Ning Hao and Bin Dong.
Maintainer: Ning Hao <[email protected]>
A new reduced-rank LDA method which works for high dimensional multi-class data.
SPCALDA(X,Y,rho=exp(c((-2):6)),K=min(20,min(dim(X))), folds = NULL)
SPCALDA(X,Y,rho=exp(c((-2):6)),K=min(20,min(dim(X))), folds = NULL)
X |
Input matrix, of dimension nobs x nvars; each row is an observation vector. |
Y |
Response variable for class label, of dimension nobs x 1. |
rho |
Tuning parameter. |
K |
The total number of principal components considered. |
folds |
Folds for cross-validation to select tuning parameter. |
ob |
lda rule with top PCs |
tuneRotation |
Tuned rotaion matrix |
minerror |
Minimal training error |
rho |
tuned value of the parameter rho |
K |
tuned dimension, i.e., number of PCs |
Yue S. Niu, Ning Hao and Bin Dong
set.seed(2015) n = 200;p = 500 X = matrix(rnorm(n*p),n,p) mu=matrix(0,4,p) mu[1,1:125]=0.4;mu[2,126:250]=0.4;mu[3,251:375]=0.4;mu[4,376:500]=0.4 Y = rep(1:4,50) for (g in 1:4) { index = which(Y == g) n_g = length(index) X[index,] = X[index,] + matrix(mu[g,],n_g,p,byrow=TRUE) } xtr = X[1:100,]; ytr=Y[1:100] #traning set xte = X[101:200,]; yte =Y[101:200] # test set folds = list(1:20,21:40,41:60,61:80,81:100) spcaldaResult = SPCALDA(X=xtr,Y=ytr,rho=exp(c((-2):6)),K=20, folds = folds) yhat = predict(spcaldaResult$ob,xte%*%spcaldaResult$tuneRotation)$class error = sum(yhat != yte)
set.seed(2015) n = 200;p = 500 X = matrix(rnorm(n*p),n,p) mu=matrix(0,4,p) mu[1,1:125]=0.4;mu[2,126:250]=0.4;mu[3,251:375]=0.4;mu[4,376:500]=0.4 Y = rep(1:4,50) for (g in 1:4) { index = which(Y == g) n_g = length(index) X[index,] = X[index,] + matrix(mu[g,],n_g,p,byrow=TRUE) } xtr = X[1:100,]; ytr=Y[1:100] #traning set xte = X[101:200,]; yte =Y[101:200] # test set folds = list(1:20,21:40,41:60,61:80,81:100) spcaldaResult = SPCALDA(X=xtr,Y=ytr,rho=exp(c((-2):6)),K=20, folds = folds) yhat = predict(spcaldaResult$ob,xte%*%spcaldaResult$tuneRotation)$class error = sum(yhat != yte)