Compute the solution path for direct sparse discriminant analysis (DSDA).
dsda(x, z=NULL, y, testx=NULL, testz=NULL, standardize=FALSE,
lambda=lambda, alpha=1, eps=1e-7)
Input matrix of predictors. x
is of dimension \(N \times p\); each row is an observation vector.
Input covariate matrix of dimension \(N \times q\), where \(q<N\). z
can be omitted if covariate is absent.
An n-dimensional vector containing the class labels. The classes have to be labeled as 1 and 2.
Input testing matrix. Each row is a test case. When testx
is not provided, the function will only fit the model and return the classifier. When testx
is provided, the function will predict response on testx
as well.
Input testing covariate matrix. Can be omitted if covariate is absent. However, training covariates z
and testing covariates testz
must be provided or not at the same time.
A logic object indicating whether x should be standardized before performing DSDA. Default is FALSE.
A sequence of lambda's. If lambda is missed, the function will automatically generates a sequence of lambda's to fit model.
The elasticnet mixing parameter, the same as in glmnet. Default is alpha=1 so that the lasso penalty is used.
Convergence threshold for coordinate descent, the same as in glmnet. Default is 1e-7.
Output variable coefficients for each lambda. The first element of each solution is the intercept.
The sequence of lambda's used in computing the solution path.
The predictor matrix in training data.
The class label in training data.
Predicted categorical response for each value in sequence lambda
when testx
is provided.
Mai, Q., Zou, H. and Yuan, M. (2013). A direct approach to sparse discriminant analysis in ultra-high dimensions. Biometrika, 99, 29-42.
# NOT RUN {
data(GDS1615) ##load the prostate data
x<-GDS1615$x
y<-GDS1615$y
x=x[which(y<3),]
y=y[which(y<3)]
obj.path <- dsda(x, y=y)
# }
Run the code above in your browser using DataLab