View source: R/compute_penalty.R
| compute_penalty | R Documentation |
Compute one or more penalty values for a given omega, allowing
vectorized specifications of penalty, lambda, and gamma.
compute_penalty(omega, penalty, lambda, gamma = NA)
omega |
A numeric value or vector at which the penalty is evaluated. |
penalty |
A character string or vector specifying one or more penalty types. Available options include:
If |
lambda |
A non-negative numeric value or vector specifying
the regularization parameter.
If |
gamma |
A numeric value or vector specifying the additional parameter
for the penalty function.
If
For |
A data frame with S3 class "penalty" containing:
The input omega values.
The penalty type for each row.
The regularization parameter used.
The additional penalty parameter used.
The computed penalty value.
The number of rows equals
max(length(penalty), length(lambda), length(gamma)).
Any of penalty, lambda, or gamma with length 1
is recycled to this common length.
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.