coef.cpernet: Get coefficients from a cpernet object

View source: R/coef.cpernet.R

coef.cpernetR Documentation

Get coefficients from a cpernet object

Description

Computes the coefficients or returns a list of the indices of the nonzero coefficients at the requested values for lambda from a fitted cpernet object.

Usage

## S3 method for class 'cpernet'
coef(object, s = NULL, type = c("coefficients", "nonzero"), ...)

Arguments

object

fitted cpernet model object.

s

value(s) of the penalty parameter lambda at which predictions are to be made. Default is the entire sequence used to create the model.

type

type "coefficients" computes coefficients at the requested values for s. Type "nonzero" returns a list of the indices of nonzero coefficients for each value of s. Default is "coefficients".

...

not used. Other arguments to predict.

Details

s is the new vector at which predictions are requested. If s is not in the lambda sequence used for fitting the model, the coef function will use linear interpolation to make predictions. The new values are interpolated using a fraction of coefficients from both left and right lambda indices.

Value

The object returned depends on type.

Author(s)

Yuwen Gu and Hui Zou

Maintainer: Yuwen Gu <yuwen.gu@uconn.edu>

See Also

cpernet, predict.cpernet, print.cpernet, plot.cpernet

Examples


set.seed(1)
n <- 100
p <- 400
x <- matrix(rnorm(n * p), n, p)
y <- rnorm(n)
tau <- 0.30
pf <- abs(rnorm(p))
pf2 <- abs(rnorm(p))
w <- 2.0
lambda2 <- 1
m2 <- cpernet(y = y, x = x, w = w, tau = tau, eps = 1e-8,
              pf.mean = pf, pf.scale = pf2, intercept = TRUE,
              standardize = FALSE, lambda2 = lambda2)

mean.coef <- as.vector(coef(m2, s = m2$lambda[50])[[1]])
scale.coef <- as.vector(coef(m2, s = m2$lambda[50])[[2]])


SALES documentation built on Aug. 16, 2022, 1:05 a.m.

Related to coef.cpernet in SALES...