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. 23, 2023, 5:09 p.m.