R/picasso.R

Defines functions picasso

Documented in picasso

picasso <- function(X,
                    Y,
                    lambda = NULL,
                    nlambda = 100,
                    lambda.min.ratio = 0.05,
                    family = "gaussian",
                    method = "l1",
                    type.gaussian = "naive",
                    gamma = 3,
                    df = NULL,
                    dfmax = NULL,
                    standardize = TRUE,
                    intercept = TRUE,
                    prec = 1e-7,
                    max.ite = 1e3,
                    verbose = FALSE)
{
  supported.family = c("gaussian", "binomial", "poisson", "sqrtlasso")
  if (!(family %in% supported.family)) {
    stop(sprintf(
      "Invalid `family`: %s. Must be one of: %s.",
      family,
      paste(supported.family, collapse = ", ")
    ))
  }

  if (family == "gaussian") {
    if (!is.matrix(Y))
      Y = as.matrix(Y)
    if (ncol(Y) != 1)
      stop("Only univariate response is supported for family = \"gaussian\" in this version.")

    out = picasso.gaussian(X = X, Y = Y, lambda = lambda, nlambda = nlambda,
                        lambda.min.ratio = lambda.min.ratio,
                        method = method, type.gaussian = type.gaussian, gamma = gamma, df = df,
                        dfmax = dfmax,
                        standardize = standardize,  intercept= intercept,
                        prec = prec,
                        max.ite = max.ite, verbose = verbose)
  } else if (family == "binomial") {
    if(!is.matrix(Y))
      Y = as.matrix(Y)
    
    out = picasso.logit(X = X, Y = Y, lambda = lambda, nlambda = nlambda,
                        lambda.min.ratio = lambda.min.ratio,
                        method = method, gamma = gamma, dfmax = dfmax,
                        standardize = standardize, intercept=intercept,
                        prec = prec, max.ite = max.ite, verbose = verbose)
  } else if (family == "sqrtlasso"){
    if(!is.matrix(Y))
      Y = as.matrix(Y)
    
    out = picasso.sqrtlasso(X = X, Y = Y, lambda = lambda, nlambda = nlambda,
                        lambda.min.ratio = lambda.min.ratio,
                        method = method, gamma = gamma, dfmax = dfmax,
                        standardize = standardize, intercept=intercept,
                        prec = prec, max.ite = max.ite, verbose = verbose)
  } else if (family=="poisson") {
    out = picasso.poisson(X = X, Y=Y, lambda = lambda, nlambda = nlambda,
                        lambda.min.ratio = lambda.min.ratio,
                       method = method, gamma = gamma, dfmax = dfmax,
                       standardize = standardize,
                       intercept = intercept,
                       prec = prec, max.ite = max.ite,
                       verbose = verbose)
  }
  out$family = family
  return(out)
}

Try the picasso package in your browser

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

picasso documentation built on March 12, 2026, 5:06 p.m.