path.order: Ordering of Predictors by Regularization Path

path.orderR Documentation

Ordering of Predictors by Regularization Path

Description

This function determines an ordering of the predictors based on the regularization path of the penalized regression; in particular, the predictors are ordered based on the order in which the coefficients are included in the model as the penalty strength decreases.

Usage

path.order(fit)

Arguments

fit

The output of a function such as glmnet from the glmnet package or ncvreg from the ncvfeg that estimates a "regularization path" for all predictors.

Value

An ordering of the predictors.

Examples

### generate synthetic data
set.seed(1)
n           = 200
p           = 300
X           = matrix(rnorm(n*p),n,p)
beta        = double(p)
beta[1:10]  = 1:10
y           = X %*% beta + rnorm(n)

### glmnet fit
library(glmnet)
fit.lasso = glmnet(X, y)
lasso.order = path.order(fit.lasso)

### ncvreg fit
library(ncvreg)
fit.scad = ncvreg(X, y)
scad.order = path.order(fit.scad)


stephenslab/mr.ash.alpha documentation built on Oct. 31, 2023, 4:21 p.m.