biglasso_fit | R Documentation |
This function is intended for users who know exactly what they're doing and want complete control over the fitting process. It
does NOT add an intercept
does NOT standardize the design matrix
does NOT set up a path for lambda (the lasso tuning parameter) all of the above are critical steps in data analysis. However, a direct API has been provided for use in situations where the lasso fitting process is an internal component of a more complicated algorithm and standardization must be handled externally.
biglasso_fit(
X,
y,
r,
init = rep(0, ncol(X)),
xtx,
penalty = "lasso",
lambda,
alpha = 1,
gamma,
ncores = 1,
max.iter = 1000,
eps = 1e-05,
dfmax = ncol(X) + 1,
penalty.factor = rep(1, ncol(X)),
warn = TRUE,
output.time = FALSE,
return.time = TRUE
)
X |
The design matrix, without an intercept. It must be a
double type |
y |
The response vector |
r |
Residuals (length n vector) corresponding to |
init |
Initial values for beta. Default: zero (length p vector) |
xtx |
X scales: the jth element should equal |
penalty |
String specifying which penalty to use. Default is 'lasso', Other options are 'SCAD' and 'MCP' (the latter are non-convex) |
lambda |
A single value for the lasso tuning parameter. |
alpha |
The elastic-net mixing parameter that controls the relative contribution from the lasso (l1) and the ridge (l2) penalty. The penalty is defined as:
|
gamma |
Tuning parameter value for nonconvex penalty. Defaults are
3.7 for |
ncores |
The number of OpenMP threads used for parallel computing. |
max.iter |
Maximum number of iterations. Default is 1000. |
eps |
Convergence threshold for inner coordinate descent. The
algorithm iterates until the maximum change in the objective
after any coefficient update is less than |
dfmax |
Upper bound for the number of nonzero coefficients. Default is no upper bound. However, for large data sets, computational burden may be heavy for models with a large number of nonzero coefficients. |
penalty.factor |
A multiplicative factor for the penalty applied to
each coefficient. If supplied, |
warn |
Return warning messages for failures to converge and model saturation? Default is TRUE. |
output.time |
Whether to print out the start and end time of the model fitting. Default is FALSE. |
return.time |
Whether to return the computing time of the model fitting. Default is TRUE. |
Note:
Hybrid safe-strong rules are turned off for biglasso_fit()
, as these rely
on standardization
Currently, the function only works with linear regression
(family = 'gaussian'
).
An object with S3 class "biglasso"
with following variables.
beta |
The vector of estimated coefficients |
iter |
A vector of length |
resid |
Vector of residuals calculated from estimated coefficients. |
lambda |
The sequence of regularization parameter values in the path. |
alpha |
Same as in |
loss |
A vector containing either the residual sum of squares of the fitted model at each value of lambda. |
penalty.factor |
Same as in |
n |
The number of observations used in the model fitting. |
y |
The response vector used in the model fitting. |
Tabitha Peter and Patrick Breheny
data(Prostate)
X <- cbind(1, Prostate$X)
xtx <- apply(X, 2, crossprod)/nrow(X)
y <- Prostate$y
X.bm <- as.big.matrix(X)
init <- rep(0, ncol(X))
fit <- biglasso_fit(X = X.bm, y = y, r=y, init = init, xtx = xtx,
lambda = 0.1, penalty.factor=c(0, rep(1, ncol(X)-1)), max.iter = 10000)
fit$beta
fit <- biglasso_fit(X = X.bm, y = y, r=y, init = init, xtx = xtx, penalty='MCP',
lambda = 0.1, penalty.factor=c(0, rep(1, ncol(X)-1)), max.iter = 10000)
fit$beta
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.