R/coef.logitpath.R

Defines functions coef.logitpath

Documented in coef.logitpath

coef.logitpath <- function(object, s = NULL, type = c("coefficients", 
    "nonzero"), ...) {
    type <- match.arg(type)
    b0 <- object$b0
    nbeta <- rbind2(b0, object$beta)
    rownames(nbeta)[1] <- "(Intercept)"
    if (!is.null(s)) {
        vnames <- dimnames(nbeta)[[1]]
        dimnames(nbeta) <- list(NULL, NULL)
        lambda <- object$lambda
        lamlist <- lambda.interp(lambda, s)
        nbeta=nbeta[,lamlist$left,drop=FALSE]%*%Diagonal(x=lamlist$frac)+nbeta[,lamlist$right,drop=FALSE]%*%Diagonal(x=1-lamlist$frac)
        dimnames(nbeta) <- list(vnames, paste(seq(along = s)))
    }
    if (type == "coefficients") 
        return(nbeta)
    if (type == "nonzero") 
        return(nonzero(nbeta[-1, , drop = FALSE], bystep = TRUE))
} 

Try the gcdnet package in your browser

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

gcdnet documentation built on Nov. 20, 2017, 5:07 p.m.