Skip to contents

Visualizes feature coefficients from a penalized regression model fitted by glmnet. Positive and negative coefficients are color-coded for better interpretation.

Usage

FeatureImportanceCoef(model)

Arguments

model

A fitted glmnet model object that includes components model and lambda, such as from the output of BuildPhenoModelAutoAlpha() or cv.glmnet().

Value

A ggplot2 object showing feature coefficients with direction-based color coding.

Details

The function extracts non-zero coefficients at the optimal lambda from a glmnet model object. It removes the intercept term and displays a horizontal bar plot using ggplot2. Coefficients are sorted to enhance readability.

Author

Bin Duan

Examples

if (FALSE) { # \dontrun{
library(glmnet)
x <- matrix(rnorm(100 * 20), nrow = 100, ncol = 20)
y <- sample(c(0, 1), 100, replace = TRUE)
fit <- cv.glmnet(x, y, family = "binomial")
FeatureImportanceCoef(model = model)
} # }