Selection by partitioning the solution paths of Lasso, Adaptive Lasso, and Ridge penalized regression.
Source:R/SPSP.R
SPSP.RdA user-friendly function to conduct the selection by Partitioning the Solution Paths (the SPSP algorithm). The
user only needs to specify the independent variables matrix, response, family, and fitfun.SP.
Arguments
- x
A matrix with all independent variables, of dimension n by p; each row is an observation vector with p variables.
- y
Response variable. Quantitative for
family="gaussian"orfamily="poisson"(non-negative counts). Forfamily="binomial"should be either a factor with two levels.- family
Response type. Either a character string representing one of the built-in families, or else a glm() family object.
- fitfun.SP
A function to obtain the solution paths for the SPSP algorithm. This function takes the arguments x, y, family as above, and additionally the standardize and intercept and others in
glmnet,ncvreg, orlars. The function fit the penalized models with lasso, adaptive lasso, SCAD, or MCP penalty, or ridge regression to return the solution path of the corresponding penalized likelihood approach.lasso.glmnetlasso selection from
glmnet.adalasso.glmnetadaptive lasso selection using the
lambda.1sefrom cross-validation lasso method to obtain initial coefficients. It uses packageglmnet.adalassoCV.glmnetadaptive lasso selection using the
lambda.1sefrom cross-validation adaptive lasso method to obtain initial coefficients. It uses packageglmnet.ridge.glmnetuse ridge regression to obtain the solution path.
SCAD.ncvreguse SCAD-penalized regression model in
ncvregto obtain the solution path.MCP.ncvreguse MCP-penalized regression model in
ncvregto obtain the solution path.lasso.larsuse lasso selection in
larsto obtain the solution path.
- args.fitfun.SP
A named list containing additional arguments that are passed to the fitting function; see also argument
args.fitfun.SPin do.call.- standardize
logical argument. Should conduct standardization before the estimation? Default is TRUE.
- intercept
logical. If x is a data.frame, this argument determines if the resulting model matrix should contain a separate intercept or not. Default is TRUE.
- ...
Additional optional arguments.
Value
An object of class "SPSP" is a list containing at least the following components:
beta_SPSPthe estimated coefficients of SPSP selected model;
S0the estimated relevant sets;
nonzerothe selected covariates;
zerothe covariates that are not selected;
thresthe boundaries for abs(beta);
Rthe sorted adjacent distances;
interceptthe estimated intercept when
intercept == T.
This object has attribute contains:
mod.fitthe fitted penalized regression within the input function
fitfun.SP;familythe family of fitted object;
fitfun.SPthe function to obtain the solution paths for the SPSP algorithm;
args.fitfun.SPa named list containing additional arguments for the function
fitfun.SP.
Examples
data(HighDim)
library(glmnet)
#> Loading required package: Matrix
#> Loaded glmnet 4.1-8
# Use the high dimensional dataset (data(HighDim)) to test SPSP+Lasso and SPSP+AdaLasso:
data(HighDim)
x <- as.matrix(HighDim[,-1])
y <- HighDim[,1]
spsp_lasso_1 <- SPSP::SPSP(x = x, y = y, family = "gaussian", fitfun.SP = lasso.glmnet,
init = 1, standardize = FALSE, intercept = FALSE)
head(spsp_lasso_1$nonzero)
#> [1] "X1" "X2" "X3"
head(spsp_lasso_1$beta_SPSP)
#> X1 X2 X3 X4 X5 X6
#> 3.034047 2.042406 1.473175 0.000000 0.000000 0.000000
spsp_adalasso_5 <- SPSP::SPSP(x = x, y = y, family = "gaussian", fitfun.SP = adalasso.glmnet,
init = 5, standardize = TRUE, intercept = FALSE)
head(spsp_adalasso_5$nonzero)
#> [1] "X1" "X2" "X3"
head(spsp_adalasso_5$beta_SPSP)
#> X1 X2 X3 X4 X5 X6
#> 3.041661 2.047532 1.476872 0.000000 0.000000 0.000000