View source: R/plot.penderiv.R
| plot.penderiv | R Documentation |
Generate a visualization of penalty functions produced by
compute_penalty, or penalty derivatives produced by
compute_derivative.
The plot automatically summarizes multiple configurations of penalty type,
\lambda, and \gamma. Optional zooming is supported through
facet_zoom.
## S3 method for class 'penderiv'
plot(x, ...)
x |
An object inheriting from S3 class |
... |
Optional arguments passed to |
An object of class ggplot.
library(grasps)
library(ggplot2)
pen_df <- compute_penalty(
omega = seq(-4, 4, by = 0.01),
penalty = c("atan", "exp", "lasso", "lq", "lsp", "mcp", "scad"),
lambda = 1)
plot(pen_df, xlim = c(-1, 1), ylim = c(0, 1), zoom.size = 1) +
guides(color = guide_legend(nrow = 2, byrow = TRUE))
deriv_df <- compute_derivative(
omega = seq(0, 4, by = 0.01),
penalty = c("atan", "exp", "lasso", "lq", "lsp", "mcp", "scad"),
lambda = 1)
plot(deriv_df) +
scale_y_continuous(limits = c(0, 1.5)) +
guides(color = guide_legend(nrow = 2, byrow = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.