Learn R Programming

SALES (version 1.0.2)

coef.cv.cpernet: Get coefficients from a cv.cpernet object

Description

This function gets coefficients from a cross-validated cpernet model, using the fitted cv.cpernet object, and the optimal value chosen for lambda.

Usage

# S3 method for cv.cpernet
coef(object, s = c("lambda.1se", "lambda.min"), ...)

Value

The object returned depends the ... argument which is passed on to the predict method for cpernet objects.

Arguments

object

fitted cv.cpernet object.

s

value(s) of the penalty parameter lambda at which predictions are required. Default is the value s="lambda.1se" stored on the CV object, it is the largest value of lambda such that error is within 1 standard error of the minimum. Alternatively s="lambda.min" can be used, it is the optimal value of lambda that gives minimum cross validation error cvm. If s is numeric, it is taken as the value(s) of lambda to be used.

...

not used. Other arguments to predict.

Author

Yuwen Gu and Hui Zou

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

Details

This function makes it easier to use the results of cross-validation to get coefficients or make coefficient predictions.

See Also

cv.cpernet, predict.cv.cpernet

Examples

Run this code

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.cv <- cv.cpernet(y = y, x = x, w = w, tau = tau, eps = 1e-8,
                    pf.mean = pf, pf.scale = pf2,
                    standardize = FALSE, lambda2 = lambda2)
as.vector(coef(m2.cv, s = "lambda.min")$beta)
as.vector(coef(m2.cv, s = "lambda.min")$theta)

Run the code above in your browser using DataLab