R/coef.q

Defines functions coef.l1celist coef.l1ce

Documented in coef.l1ce coef.l1celist

###  Copyright (C) 1998
###  Berwin A. Turlach <bturlach@stats.adelaide.edu.au>
###  Bill Venables <wvenable@stats.adelaide.edu.au>
### --> ../COPYRIGHT for more details

coef.l1ce <- function(object, all=TRUE, constrained=FALSE, ...)
{
    label <- if(constrained) "constrained.coefficients" else "coefficients"
    if(all)
        object[[label]]
    else
        object[[label]][abs(object[[label]]) > sqrt(.Machine$double.eps)]
}

coef.l1celist <- function(object, all=TRUE, constrained=FALSE, ...)
{
    label <- if(constrained) "constrained.coefficients" else "coefficients"
    if(all) {
        do.call("rbind", lapply(object, "[[", label))
    }
    else {
        junk <- do.call("rbind", lapply(object, "[[", label))
        ind <- apply(abs(junk), 2, sum)
        junk[, ind != 0]
    }
}

Try the lasso2 package in your browser

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

lasso2 documentation built on Oct. 8, 2021, 9:10 a.m.