mul.sdwd: Multiway Sparse Distance Weighted Discrimination

Description Usage Arguments Value Examples

View source: R/mul.sdwd.r

Description

Optimize sparse DWD objective for a multiway dataset with any dimension. L1 and L2 parameters are imposed to enforce sparsity in the model.

Usage

1
mul.sdwd(X, y, R = 1, lambda1 = 0, lambda2 = 1, convThresh = 1e-05, nmax = 500)

Arguments

X

A multiway array with dimensions N \times P_1 \times ... \times P_K. The first dimension (N) give the cases (e.g.subjects) to be classified.

y

A vector of length N with class label (-1 or 1) for each case.

R

Assumed rank of the coefficient array.

lambda1

The L1 tuning parameter lambda1 that enforce sparsity. lambda1 and lambda2 can be determined by the function lambda.mul.sdwd.

lambda2

The L2 tuning paprameter lambda2.

convThresh

The algorithm stops when the distance between B_new and B_old is less than convThresh. Default is 1e-7.

nmax

Restrics how many iterations are allowed. Default is 500.

Value

A list of components

beta Vector of coefficients with length P_1 \times ... \times P_K.

int Intercept.

U A list of K matrices. Each matrix (P_k \times R) corresponds to the estimated weights for k^th dimension.

If R=1, U is a list of K vectors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Load gene expression time course data (?IFNB_Data for more info)
data(IFNB_Data)
Class=2*(Class-1)-1 #redefine classes to -1 or 1

## Run Multiway SDWD
res.msdwd1 <- mul.sdwd(DataArray,y=Class,R=1,lambda1=0,lambda2=1,convThresh = 1e-5, nmax=500)

##Compute projection onto the classification direction for each individual:
scores <- c()
for(i in 1:length(Class)) scores[i] = sum(as.vector(DataArray[i,,])*res.msdwd1$beta)+res.msdwd1$int
Colors=rep(1,length(Class))
Colors[Class==1]=2
plot(scores, col=Colors)

lockEF/MultiwayClassification documentation built on Dec. 17, 2020, 11:01 a.m.