SPSP_step {SPSP}R Documentation

The selection step with the input of the solution paths.

Description

A function to select the relevant predictors by partitioning the solution paths (the SPSP algorithm) based on the user provided solution paths BETA.

Usage

SPSP_step(
  x,
  y,
  family = c("gaussian", "binomial"),
  BETA,
  standardize = TRUE,
  intercept = TRUE,
  init = 1,
  R = NULL,
  ...
)

Arguments

x

independent variables as a matrix, of dimension nobs x nvars; each row is an observation vector.

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

either a character string representing one of the built-in families, or else a glm() family object.

BETA

the solution paths obtained from a prespecified fitting step fitfun.SP = lasso.glmnet etc. It must be a p by k matrix, should be thicker and thicker, each column corresponds to a lambda, and lambda gets smaller and smaller. It is the returned coefficient matrix beta from a glmnet object, or a ncvreg object.

standardize

whether need standardization.

intercept

logical. If x is a data.frame, this argument determines if the resulting model matrix should contain a separate intercept or not.

init

initial coefficients, starting from init-th estimator of the solution paths. The default is 1.

R

sorted adjacent distances, default is NULL. Will be calculated inside.

...

Additional optional arguments.

Value

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)

x <- as.matrix(HighDim[,-1])
y <- HighDim[,1]

lasso_fit <- glmnet(x = x, y = y, alpha = 1, intercept = FALSE)

# SPSP+Lasso method
K <- dim(lasso_fit$beta)[2]
LBETA <- as.matrix(lasso_fit$beta)

spsp_lasso_1 <- SPSP_step(x = x, y = y, BETA = LBETA, 
                          init = 1, standardize = FALSE, intercept = FALSE)
head(spsp_lasso_1$nonzero)
head(spsp_lasso_1$beta_SPSP)


[Package SPSP version 0.2.0 Index]