Learn R Programming

msgl (version 0.1.3)

msgl.subsampling: Multinomial sparse group lasso generic subsampling procedure

Description

Support the use of multiple processors.

Usage

msgl.subsampling(x, classes,
    sampleWeights = rep(1/length(classes), length(classes)),
    grouping = NULL, groupWeights = NULL,
    parameterWeights = NULL, alpha = 0.5,
    standardize = TRUE, lambda, training, test,
    sparse.data = FALSE, max.threads = 2L,
    algorithm.config = sgl.standard.config)

Arguments

x
design matrix, matrix of size $N \times p$.
classes
classes, factor of length $N$.
sampleWeights
sample weights, a vector of length $N$.
grouping
grouping of covariates, a vector of length $p$. Each element of the vector specifying the group of the covariate.
groupWeights
the group weights, a vector of length $m+1$ (the number of groups). The first element of the vector is the intercept weight. If groupWeights = NULL default weights will be used. Default weights are 0 for the intercept and $$\sqrt{K\cd
parameterWeights
a matrix of size $K \times (p+1)$. The first column of the matrix is the intercept weights. Default weights are is 0 for the intercept weights and 1 for all other weights.
alpha
the $\alpha$ value 0 for group lasso, 1 for lasso, between 0 and 1 gives a sparse group lasso penalty.
standardize
if TRUE the covariates are standardize before fitting the model. The model parameters are returned in the original scale.
lambda
the lambda sequence for the regularization path.
training
a list of training samples, each item of the list corresponding to a subsample. Each item in the list must be a vector with the indices of the training samples for the corresponding subsample. The length of the list must equal the length of the
test
a list of test samples, each item of the list corresponding to a subsample. Each item in the list must be vector with the indices of the test samples for the corresponding subsample. The length of the list must equal the length of the traini
sparse.data
if TRUE x will be treated as sparse, if x is a sparse matrix it will be treated as sparse by default.
max.threads
the maximal number of threads to be used
algorithm.config
the algorithm configuration to be used.

Value

  • linkthe linear predictors -- a list of length length(test) with each element of the list another list of length length(lambda) one item for each lambda value, with each item a matrix of size $K \times N$ containing the linear predictors.
  • responsethe estimated probabilities -- a list of length length(test) with each element of the list another list of length length(lambda) one item for each lambda value, with each item a matrix of size $K \times N$ containing the probabilities.
  • classesthe estimated classes -- a list of length length(test) with each element of the list a matrix of size $N \times d$ with $d=$length(lambda).
  • featuresnumber of features used in the models.
  • parametersnumber of parameters used in the models.

Examples

Run this code
data(SimData)
x <- sim.data$x
classes <- sim.data$classes
lambda <- msgl.lambda.seq(x, classes, alpha = .5, d = 100L, lambda.min = 0.03)

test <- replicate(5, sample(1:length(classes))[1:20], simplify = FALSE)
train <- lapply(test, function(s) (1:length(classes))[-s])

fit.sub <- msgl.subsampling(x, classes, alpha = .5, lambda = lambda,
 training = train, test = test)

# Missclassification count of second subsample
colSums(fit.sub$classes[[2]] != classes[test[[2]]])

Run the code above in your browser using DataLab