predict.sgp {SGPR} | R Documentation |
Predictions based on a SGP model
Description
A function that extracts information from a SGP object and performs predictions.
Usage
## S3 method for class 'sgp'
predict(
object,
X = NULL,
extract = c("link", "response", "class", "coef", "vars", "groups", "nvars", "ngroups",
"norm"),
lambda,
index = 1:length(object$lambda),
...
)
Arguments
object |
A object that was generated with sgp. |
X |
The design matrix for making predictions. |
extract |
A string indicating the type of information to return. |
lambda |
The value of lambda at which predictions should be made. |
index |
The index that indicates the lambda at which predictions should be made (alternative to specifying 'lambda'). |
... |
Other parameters of underlying basic functions. |
Value
Different objects depending on the sting indicated by 'extract'.
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(X, y_lin, g, type = "linear")
predict(lin_fit, X = X, extract = "nvars")
log_fit <- sgp(X, y_log, g, type = "logit")
predict(log_fit, X = X, extract = "nvars")
[Package SGPR version 0.1.2 Index]