| StabilityPath | R Documentation |
Class of object returned by the QuadrupenFit$cross_validate() method or the
cross_validate() function. Owns print() and plot() methods.
probabilitiesa Matrix object containing the
estimated probabilities of selection along the path of solutions.
regParama list with the levels of the regularizing parameters used
subsamplesa list that contains the folds used for each subsample.
nvarnumber of variables (without intercept)
nobsnumber of observation/sample size
nonzerovariables with a non-null probability of selection along the stability path
nonzeroprobsubset of the probabilities stability path on the nonzero variables
StabilityPath$new()Constructor for a StabilityPath object
Should be called internally by an object QuadrupenFit$stability()
StabilityPath$new(probabilities, regParam, subsamples)
probabilitiesa Matrix object containing the
estimated probabilities of selection along the path of solutions.
regParama list with the levels of the regularizing parameters used
subsamplesa list that contains the folds used for each subsample.
StabilityPath$show()User friendly print method
StabilityPath$show()
StabilityPath$print()User friendly print method
StabilityPath$print()
StabilityPath$selection()Perform variable selection based on the stability path
StabilityPath$selection(
sel_mode = c("rank", "PFER"),
cutoff = 0.75,
PFER = 2,
nvarsel = floor(self$nobs/log(self$nvar))
)
sel_modea character string, either "rank" or
"PFER". In the first case, the selection is based on the
rank of total probabilities by variables along the path: the first
nvarsel variables are selected (see below). In the second
case, the PFER control is used as described in Meinshausen and
Buhlmannn's paper. Default is "rank".
cutoffvalue of the cutoff probability (only relevant when
sel_mode equals "PFER").
PFERvalue of the per-family error rate to control (only
relevant when sel_mode equals "PFER").
nvarselnumber of variables selected (only relevant when
sel_mode equals "rank". Default is floor(n/log(p)).
StabilityPath$plot()Produce a plot of the stability path obtained by stability selection.
StabilityPath$plot(
xvar = "lambda",
title = "Stability path",
labels = rep("unknown status", self$nvar),
sel_mode = c("rank", "PFER"),
cutoff = 0.75,
PFER = 2,
nvarsel = min(self$nvar, floor(self$nobs/log(self$nvar)))
)
xvarvariable to plot on the X-axis: either "lambda"
(first penalty level) or "fraction" (fraction of the
penalty level applied tune by \lambda_1). Default
is "lambda".
titletitle title. If none given, a somewhat appropriate title is automatically generated.
labelsan optional vector of labels for each variable in the path (e.g., 'relevant'/'irrelevant'). See examples.
sel_modea character string, either "rank" or
"PFER". In the first case, the selection is based on the
rank of total probabilities by variables along the path: the first
nvarsel variables are selected (see below). In the second
case, the PFER control is used as described in Meinshausen and
Buhlmannn's paper. Default is "rank".
cutoffvalue of the cutoff probability (only relevant when
sel_mode equals "PFER").
PFERvalue of the per-family error rate to control (only
relevant when sel_mode equals "PFER").
nvarselnumber of variables selected (only relevant when
sel_mode equals "rank". Default is floor(n/log(p)).
plotlogical; indicates if the graph should be
plotted. Default is TRUE. If FALSE, only the
ggplot2 object is sent back.
a list with a ggplot2 object which can be plotted
via the print method, and a vector of selected variables
corresponding to method of choice ("rank" or
"PFER").
## 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 <- Matrix::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"))
enet <- elastic_net(x, y, lambda2 = 10, struct = solve(Sigma), minratio = 1e-2)
stab <- stability(enet, n_subsamples = 200)
## Build the plot an recover the selected variable
plot(stab, labels=labels)
cat("\nFalse positives for the randomized Elastic-net with stability selection: ",
sum(labels[stab$selection()] != "relevant"))
cat("\nDONE.\n")
StabilityPath$clone()The objects of this class are cloneable with this method.
StabilityPath$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `StabilityPath$plot()`
## ------------------------------------------------
## Not run:
## 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 <- Matrix::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"))
enet <- elastic_net(x, y, lambda2 = 10, struct = solve(Sigma), minratio = 1e-2)
stab <- stability(enet, n_subsamples = 200)
## Build the plot an recover the selected variable
plot(stab, labels=labels)
cat("\nFalse positives for the randomized Elastic-net with stability selection: ",
sum(labels[stab$selection()] != "relevant"))
cat("\nDONE.\n")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.