Learn R Programming

DAP (version 1.0)

solve_DAP_C: Solves DAP optimization problem for a given lambda value

Description

Uses block-coordinate descent algorithm to solve DAP problem.

Usage

solve_DAP_C(X1, X2, lambda, Vinit = NULL, eps = 1e-04, maxiter = 10000)

Arguments

X1

A n1 x p matrix of group 1 data (scaled).

X2

A n2 x p matrix of group 2 data (scaled).

lambda

A value of the tuning parameter lambda.

Vinit

Optional starting point, the default is NULL, and the algorithm starts with the matrix of zeros.

eps

Convergence threshold for the block-coordinate decent algorithm based on the maximum element-wise change in \(V\). The default is 1e-4.

maxiter

Maximum number of iterations, the default is 10000.

Value

A list of

V

A p x 2 projection matrix to be used in DAP classification algorithm.

nfeature

Number of nonzero features.

iter

Number of iterations until convergence.

Warnings

Please use scaled X1 and X2 for this function, they can be obtained using standardizeData to do so.

Examples

Run this code
# NOT RUN {
## This is an example for solve_DAP_C

## Generate data
n_train = 50
n_test = 50
p = 100
mu1 = rep(0, p)
mu2 = rep(3, p)
Sigma1 = diag(p)
Sigma2 = 0.5* diag(p)

## Build training data
x1 = MASS::mvrnorm(n = n_train, mu = mu1, Sigma = Sigma1)
x2 = MASS::mvrnorm(n = n_train, mu = mu2, Sigma = Sigma2)
xtrain = rbind(x1, x2)
ytrain = c(rep(1, n_train), rep(2, n_train))

## Standardize the data
out_s = standardizeData(xtrain, ytrain, center = FALSE)

## Apply solve_DAP_C
out = solve_DAP_C(X1 = out_s$X1, X2 = out_s$X2, lambda = 0.3)
# }

Run the code above in your browser using DataLab