Last chance! 50% off unlimited learning
Sale ends in
Visualize the coefficient path resulting from the elastic net
coefpath(model, ...)# S3 method for glmnet
coefpath(
model,
xlab = "Log Lambda",
ylab = "Coefficients",
showLegend = c("onmouseover", "auto", "always", "follow", "never"),
annotate = TRUE,
elementID = NULL,
...
)
# S3 method for 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"),
...
)
A glmnet
model
Arguments passed on to extractPath
x-axis label
y-axis label
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.
If TRUE
(default) plot the name of the series
Unique identified for dygraph, if NULL
it will be randomly generated
Color for line showing lambda.min
Stroke pattern for line showing lambda.min
Label for line showing lambda.min
Location for line showing lambda.min, can be 'bottom' or 'top'
Color for line showing lambda.1se
Stroke pattern for line showing lambda.1se
Label for line showing lambda.1se
Location for line showing lambda.1se, can be 'bottom' or 'top'
A dygraphs object
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.
# NOT RUN {
# }
# NOT RUN {
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)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab