R/lasso.compreg.R

Defines functions lasso.compreg

Documented in lasso.compreg

lasso.compreg <- function(y, x, alpha = 1, lambda = NULL, nlambda = 100, xnew = NULL) {
  y <- Compositional::alr(y)
  mod <- glmnet::glmnet(x, y, alpha = alpha, nlambda = nlambda, lambda = lambda, family = "mgaussian")
  est <- NULL
  
  if ( !is.null(xnew) ) {
    est <- predict(mod, newx = xnew)
  }
  
  list(mod = mod, est = est)
}

Try the Compositional package in your browser

Any scripts or data that you put into this service are public.

Compositional documentation built on Oct. 9, 2024, 5:10 p.m.