View source: R/autotune_lasso.R
| autotune_lasso | R Documentation |
Fits a linear model via alternative optimization of penalized gaussian maximum likelihood
which is a biconvex function of regression coefficients \beta and noise variance \sigma^2.
The regularization path of autotune_lasso quickly picks out a good lambda for Lasso and then
returns the corresponding linear fit along with various attributes related to the fit.
autotune_lasso(
x,
y,
alpha = 0.01,
standardize = TRUE,
standardize_response = TRUE,
intercept = TRUE,
active = FALSE,
trace_it = FALSE,
tolerance = 1e-04,
beta_tolerance = 0.001,
iter_max = 30,
beta_iter_max = 40,
active_iter_max = 5,
PR_norm_l2 = FALSE,
...
)
x |
Matrix of predictors, with one column for each predictor.
Dimension will be |
y |
Vector of responses. |
alpha |
Default 0.01, significance level of sequential F-tests used for estimation of support set. |
standardize |
Logical flag for standardization of all variables in x, prior to
fitting the model sequence. The coefficients are always returned on the
original scale. Default value is |
standardize_response |
Logical flag for demeaning the reponse variable y.
Default value is |
intercept |
Should intercept(s) be fitted (default= |
active |
Should active set selection be used ( |
trace_it |
Logical input, default |
tolerance |
Numeric input for an additional stopping criteria on the
coordinate descent when sigma is updating. Stops that coordinate
descent when the relative change between successive iterates of
coefficients' estimates is less than the |
beta_tolerance |
Numeric input for the stopping criteria on the
coordinate descent when sigma is not updating. Stops that coordinate
descent when the relative change between successive iterates of
coefficients' estimates is less than the |
iter_max |
Maximum number of iterations of coordinate descent allowed when sigma is updating. Default value is 30. |
beta_iter_max |
Maximum number of iterations of coordinate descent allowed when sigma is not updating. Default value is 40. |
active_iter_max |
If |
PR_norm_l2 |
Logical flag to whether use the l2 norm of partial residuals for ordering them instead of the default l1 norm. |
... |
Additional arguments passed to the internal fitting routine. |
A list with various intermediate and final outputs produced by autotune Lasso in its regularization path.
beta |
Final estimates of regression coefficients. |
a0 |
Intercept of the fit. |
lambda |
Final thresholding value |
sigma_sq |
Final estimate of noise variance |
nobs |
Number of observations. |
nvars |
Number of variables. |
CD.path.details |
A list of additional details about the coordinate descent path taken by autotune Lasso:
|
library(autotune)
set.seed(10)
n <- 80
p <- 400
s <- 5
snr <- 4
betatrue <- c(rep(1,s), rep(0, p - s))
x <- matrix(rnorm(n * p), ncol = p)
error.sd <- sqrt((betatrue %*% betatrue)/snr)
err <- rnorm(n, sd = error.sd)
y <- x %*% betatrue + err
ans <- autotune_lasso(x, y, trace_it = TRUE)
b <- betatrue
# The Predictors which are actually significant:
which(b != 0)
# The Predictors which had nonzero estmated coefficients:
which(ans$beta != 0)
# Top 10 predictors X_i's in the ranking of X_i's given by autotune:
ans$CD.path.details$sorted_predictors[1:10]
# Cardinality of autotune's estimated support set in each CD iteration before lambda converged:
ans$CD.path.details$count_sig_beta
# Sigma estimates in each CD iteration:
ans$CD.path.details$sigma_sq_seq
# Empirical noise variance:
var(err)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.