solve_lbfgsb <- function(X, Y, lambda, beta0,
constraint_type = c("beta", "yhat", "none"), ...){
constraint_type <- match.arg(constraint_type)
if (constraint_type == "yhat") {
stop("The constraint 'yhat' is not available for L-BFGS-B solving.")
}
upbbound <- ifelse(constraint_type == "beta", 0, Inf)
opt <- optim(par = beta0,
fn = compute_objective_function(Y, X, lambda, type = "lasso"),
gr = compute_gradient_function(Y, X, lambda),
upper = upbbound, method = "L-BFGS-B")
# ... removed because optim is closed
opt <- c(opt, method = "L-BFGS-B")
opt
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.