glmnet_filter | R Documentation |

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

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

`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 |

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.

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.

glmnet

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.