glmnet_filter: glmnet filter

View source: R/filters.R

glmnet_filterR Documentation

glmnet filter

Description

Filter using properties of elastic net regression using glmnet to calculate variable importance.

Usage

glmnet_filter(
  y,
  x,
  nfilter = NULL,
  method = c("mean", "nonzero"),
  type = c("index", "names", "full"),
  ...
)

Arguments

y

Response vector

x

Matrix of predictors

nfilter

Number of predictors to return

method

String indicating method of determining variable importance. "mean" (the default) uses the mean absolute coefficients across the range of lambdas; "nonzero" counts the number of times variables are retained in the model across all values of lambda.

type

Type of vector returned. Default "index" returns indices, "names" returns predictor names, "full" returns full output.

...

Other arguments passed to glmnet

Details

The glmnet elastic net mixing parameter alpha can be varied to include a larger number of predictors. Default alpha = 1 is pure LASSO, resulting in greatest sparsity, while alpha = 0 is pure ridge regression, retaining all predictors in the regression model. Note, the family argument is commonly needed, see glmnet.

Value

Integer vector of indices of filtered parameters (type = "index") or character vector of names (type = "names") of filtered parameters. If type is "full" a named vector of variable importance is returned.

See Also

glmnet


nestedcv documentation built on Oct. 23, 2022, 5:06 p.m.