coef.sgp.cv {SGPR} | R Documentation |
Coefficients from SGP models
Description
A function that extracts the estimated coefficients from an cross-validated SGP object.
Usage
## S3 method for class 'sgp.cv'
coef(object, lambda = object$lambda.min, index = object$min, ...)
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. |
Value
A vector or matrix with the estimated coefficients.
Examples
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)
[Package SGPR version 0.1.2 Index]