lambda_alpha_grid {ensr} | R Documentation |
Lambda Alpha Grid
Description
Construct a data frame with values for lambda and alpha with an indicator to know if the model is worth fitting.
Usage
lambda_alpha_grid(lambdas, alphas, nlambda = 10L, lmin_factor = 1e-04)
Arguments
lambdas |
a vector of max lambda values for each alpha given |
alphas |
a vector of alpha values corresponding to the max lambdas |
nlambda |
number of lambdas to generate for each alpha before creating the grid |
lmin_factor |
the smallest lambda value is defined as |
Examples
data(tbi)
Xmat <- model.matrix( ~ . - injury1 - injury2 - injury3 - 1, data = tbi)
Yvec <- matrix(tbi$injury1, ncol = 1)
alphas <- seq(0, 1, length = 20)
lga <- lambda_alpha_grid(alphas = alphas, lambdas = lambda_max(Yvec, Xmat, alpha = alphas))
ggplot2::ggplot() +
ggplot2::theme_bw() +
ggplot2::aes_string(x = "a", y = "log10(l)") +
ggplot2::geom_path(data = lga$top) +
ggplot2::geom_point(data = lga$lgrid,
mapping = ggplot2::aes(color = cos(a) + sin(log10(l)))) +
ggplot2::geom_contour(data = lga$lgrid,
mapping = ggplot2::aes(z = cos(a) + sin(log10(l)))) +
ggplot2::scale_color_gradient2(low = "blue", high = "red", mid = "grey")
[Package ensr version 0.1.0 Index]