Learn R Programming

SGPR (version 0.1.2)

coef.sgp.cv: Coefficients from SGP models

Description

A function that extracts the estimated coefficients from an cross-validated SGP object.

Usage

# S3 method for sgp.cv
coef(object, lambda = object$lambda.min, index = object$min, ...)

Value

A vector or matrix with the estimated coefficients.

Arguments

object

A object that was generated with sgp.cv.

lambda

The value of lambda at which the coefficients are to be extracted.

index

The index that indicates the lambda at which the coefficients are to be extracted (alternative to specifying 'lambda').

...

Other parameters of underlying basic functions.

Examples

Run this code
n <- 100
p <- 12
nr <- 4
g <- paste0("Group ",ceiling(1:p / nr))
X <- matrix(rnorm(n * p), n, p)
b <- c(-3:3)
y_lin <- X[, 1:length(b)] %*% b + 5 * rnorm(n)
y_log <- rbinom(n, 1, exp(y_lin) / (1 + exp(y_lin)))

lin_fit <- sgp.cv(X, y_lin, g, type = "linear")
coef(lin_fit)

log_fit <- sgp.cv(X, y_log, g, type = "logit")
coef(log_fit)

Run the code above in your browser using DataLab