View source: R/regularizationWeights.R
regularizationWeights | R Documentation |
This function generates sequences of regularizations weights for use in
SLOPE()
(or elsewhere).
regularizationWeights( n_lambda = 100, type = c("bh", "gaussian", "oscar", "lasso"), q = 0.2, theta1 = 1, theta2 = 0.5, n = NULL )
n_lambda |
The number of lambdas to generate. This should typically be equal to the number of predictors in your data set. |
type |
The type of lambda sequence to use. See documentation for
in |
q |
parameter controlling the shape of the lambda sequence, with
usage varying depending on the type of path used and has no effect
is a custom |
theta1 |
parameter controlling the shape of the lambda sequence
when |
theta2 |
parameter controlling the shape of the lambda sequence
when |
n |
The number of rows (observations) in the design matrix. |
Please see SLOPE()
for detailed information regarding the parameters in
this function, in particular the section Regularization Sequences.
Note that these sequences are automatically scaled (unless a value for
the alpha
parameter is manually supplied) when using SLOPE()
. In this
function, nu such scaling is attempted.
A vector of length n_lambda
with regularization weights.
SLOPE()
# compute different penalization sequences bh <- regularizationWeights(100, q = 0.2, type = "bh") gaussian <- regularizationWeights( 100, q = 0.2, n = 300, type = "gaussian" ) oscar <- regularizationWeights( 100, theta1 = 1.284, theta2 = 0.0182, type = "oscar" ) lasso <- regularizationWeights(100, type = "lasso") * mean(oscar) # Plot a comparison between these sequences plot(bh, type = "l", ylab = expression(lambda)) lines(gaussian, col = "dark orange") lines(oscar, col = "navy") lines(lasso, col = "red3") legend( "topright", legend = c("BH", "Gaussian", "OSCAR", "lasso"), col = c("black", "dark orange", "navy", "red3"), lty = 1 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.