Learn R Programming

quadrupen (version 0.2-13)

stability: Stability selection for a quadrupen fit.

Description

Compute the stability path of a (possibly randomized) fitting procedure as introduced by Meinshausen and Buhlmann (2010).

Usage

stability(
  x,
  y,
  penalty = c("elastic.net", "bounded.reg"),
  subsamples = 100,
  sample.size = floor(n/2),
  randomize = TRUE,
  weakness = 0.5,
  verbose = TRUE,
  folds = replicate(subsamples, sample(1:nrow(x), sample.size), simplify = FALSE),
  mc.cores = 1,
  ...
)

Value

An object of class stability.path.

Arguments

x

matrix of features, possibly sparsely encoded (experimental). Do NOT include intercept.

y

response vector.

penalty

a string for the fitting procedure used for cross-validation. Either elastic.net or "bounded.reg".

subsamples

integer indicating the number of subsamplings used to estimate the selection probabilities. Default is 100.

sample.size

integer indicating the size of each subsamples. Default is floor(n/2).

randomize

Should a randomized version of the fitting procedure by used? Default is TRUE. See details below.

weakness

Coefficient used for randomizing. Default is 0.5. Ignored when randomized is FALSE. See details below.

verbose

logical; indicates if the progression should be displayed. Default is TRUE.

folds

list with subsamples entries with vectors describing the folds to use for the stability procedure. By default, the folds are randomly sampled with the specified subsamples argument.

mc.cores

the number of cores to use. The default uses 1 core.

...

additional parameters to overwrite the defaults of the fitting procedure. See the corresponding documentation (elastic.net or bounded.reg)

References

N. Meinshausen and P. Buhlmann (2010). Stability Selection, JRSS(B).

See Also

stability.path and plot,stability.path-method.

Examples

Run this code
## Simulating multivariate Gaussian with blockwise correlation
## and piecewise constant vector of parameters
beta <- rep(c(0,1,0,-1,0), c(25,10,25,10,25))
Soo  <- matrix(0.75,25,25) ## bloc correlation between zero variables
Sww  <- matrix(0.75,10,10) ## bloc correlation between active variables
Sigma <- bdiag(Soo,Sww,Soo,Sww,Soo) + 0.2
diag(Sigma) <- 1
n <- 100
x <- as.matrix(matrix(rnorm(95*n),n,95) %*% chol(Sigma))
y <- 10 + x %*% beta + rnorm(n,0,10)

## Build a vector of label for true nonzeros
labels <- rep("irrelevant", length(beta))
labels[beta != 0] <- c("relevant")
labels <- factor(labels, ordered=TRUE, levels=c("relevant","irrelevant"))

## Call to stability selection function, 200 subsampling
stab <- stability(x,y, subsamples=200, lambda2=1, min.ratio=1e-2)
## Recover the selected variables for a given cutoff
## and per-family error rate, without producing any plot
stabpath <- plot(stab, cutoff=0.75, PFER=1, plot=FALSE)

cat("\nFalse positives for the randomized Elastic-net with stability selection: ",
     sum(labels[stabpath$selected] != "relevant"))
cat("\nDONE.\n")

Run the code above in your browser using DataLab