absolute.order: Ordering of Predictors from Coefficient Estimates

absolute.orderR Documentation

Ordering of Predictors from Coefficient Estimates

Description

This function orders the predictors by decreasing order of the magnitude of the estimated regression coefficient.

Usage

absolute.order(beta)

Arguments

beta

A vector of estimated regression coefficients.

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)
beta.lasso = coef(cv.glmnet(X, y))[-1]
lasso.order = absolute.order(beta.lasso)

### ncvreg fit
library(ncvreg)
beta.scad = c(coef(cv.ncvreg(X, y))[-1])
scad.order = absolute.order(beta.scad)


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