Skip to contents

A 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.

Usage

SPSP(
  x,
  y,
  family = c("gaussian", "binomial"),
  fitfun.SP = adalasso.glmnet,
  args.fitfun.SP = list(),
  standardize = TRUE,
  intercept = TRUE,
  ...
)

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" or family="poisson" (non-negative counts). For family="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, or lars. 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.glmnet

lasso selection from glmnet.

adalasso.glmnet

adaptive lasso selection using the lambda.1se from cross-validation lasso method to obtain initial coefficients. It uses package glmnet.

adalassoCV.glmnet

adaptive lasso selection using the lambda.1se from cross-validation adaptive lasso method to obtain initial coefficients. It uses package glmnet.

ridge.glmnet

use ridge regression to obtain the solution path.

SCAD.ncvreg

use SCAD-penalized regression model in ncvreg to obtain the solution path.

MCP.ncvreg

use MCP-penalized regression model in ncvreg to obtain the solution path.

lasso.lars

use lasso selection in lars to 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.SP in 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_SPSP

the estimated coefficients of SPSP selected model;

S0

the estimated relevant sets;

nonzero

the selected covariates;

zero

the covariates that are not selected;

thres

the boundaries for abs(beta);

R

the sorted adjacent distances;

intercept

the estimated intercept when intercept == T.

This object has attribute contains:

mod.fit

the fitted penalized regression within the input function fitfun.SP;

family

the family of fitted object;

fitfun.SP

the function to obtain the solution paths for the SPSP algorithm;

args.fitfun.SP

a 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