Filter using sparsity of elastic net regression using glmnet to calculate variable importance.
glmnet_filter(
y,
x,
family = NULL,
force_vars = NULL,
nfilter = NULL,
method = c("mean", "nonzero"),
type = c("index", "names", "full"),
...
)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.
Response vector
Matrix of predictors
Either a character string representing one of the built-in
families, or else a glm() family object. See glmnet::glmnet(). If not
specified, the function tries to set this automatically to one of either
"gaussian", "binomial" or "multinomial".
Vector of column names x which have no shrinkage and are
always included in the model.
Number of predictors to return
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 of vector returned. Default "index" returns indices, "names" returns predictor names, "full" returns full output.
Other arguments passed to glmnet::glmnet
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::glmnet.
glmnet::glmnet