coefpath | R Documentation |
Visualize the coefficient path resulting from the elastic net
coefpath(model, ...) ## S3 method for class 'glmnet' coefpath( model, xlab = "Log Lambda", ylab = "Coefficients", showLegend = c("onmouseover", "auto", "always", "follow", "never"), annotate = TRUE, elementID = NULL, ... ) ## S3 method for class 'cv.glmnet' coefpath( model, xlab = "Log Lambda", ylab = "Coefficients", showLegend = c("onmouseover", "auto", "always", "follow", "never"), annotate = TRUE, colorMin = "black", strokePatternMin = "dotted", labelMin = "lambda.min", locMin = c("bottom", "top"), color1se = "black", strokePattern1se = "dotted", label1se = "lambda.1se", loc1se = c("bottom", "top"), ... )
model |
A |
... |
Arguments passed on to |
xlab |
x-axis label |
ylab |
y-axis label |
showLegend |
When to display the legend. Specify "always" to always show the legend. Specify "onmouseover" to only display it when a user mouses over the chart. Specify "follow" to have the legend show as overlay to the chart which follows the mouse. The default behavior is "auto", which results in "always" when more than one series is plotted and "onmouseover" when only a single series is plotted. |
annotate |
If |
elementID |
Unique identified for dygraph, if |
colorMin |
Color for line showing lambda.min |
strokePatternMin |
Stroke pattern for line showing lambda.min |
labelMin |
Label for line showing lambda.min |
locMin |
Location for line showing lambda.min, can be 'bottom' or 'top' |
color1se |
Color for line showing lambda.1se |
strokePattern1se |
Stroke pattern for line showing lambda.1se |
label1se |
Label for line showing lambda.1se |
loc1se |
Location for line showing lambda.1se, can be 'bottom' or 'top' |
This is a replacement plot for visualizing the coefficient path resulting from the elastic net. This allows for interactively inspecting the plot so it is easier to disambiguate the coefficients.
A dygraphs object
Jared P. Lander
library(glmnet) library(ggplot2) library(useful) data(diamonds) diaX <- useful::build.x(price ~ carat + cut + x - 1, data=diamonds, contrasts = TRUE) diaY <- useful::build.y(price ~ carat + cut + x - 1, data=diamonds) modG1 <- glmnet(x=diaX, y=diaY) coefpath(modG1) modG2 <- cv.glmnet(x=diaX, y=diaY, nfolds=5) coefpath(modG2) x <- matrix(rnorm(100*20),100,20) y <- rnorm(100) fit1 <- glmnet(x, y) coefpath(fit1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.