predict.grpreg {grpreg} | R Documentation |
Model predictions based on a fitted grpreg
object
Description
Similar to other predict methods, this function returns
predictions from a fitted "grpreg"
object.
Usage
## S3 method for class 'grpreg'
predict(object, X, type=c("link", "response", "class",
"coefficients", "vars", "groups", "nvars", "ngroups", "norm"), lambda,
which=1:length(object$lambda), ...)
## S3 method for class 'grpreg'
coef(object, lambda, which=1:length(object$lambda),
drop=TRUE, ...)
## S3 method for class 'cv.grpreg'
predict(object, X, lambda=object$lambda.min,
which=object$min, type=c("link", "response", "class", "coefficients",
"vars", "groups", "nvars", "ngroups", "norm"), ...)
## S3 method for class 'cv.grpreg'
coef(object, lambda=object$lambda.min,
which=object$min, ...)
Arguments
object |
Fitted |
X |
Matrix of values at which predictions are to be made. Not
used for |
lambda |
Values of the regularization parameter |
which |
Indices of the penalty parameter |
type |
Type of prediction: |
drop |
By default, if a single value of |
... |
Not used. |
Details
coef
and predict
methods are provided for
"cv.grpreg"
options as a convenience. They simply call
coef.grpreg
and predict.grpreg
with lambda
set to
the value that minimizes the cross-validation error.
Value
The object returned depends on type.
Author(s)
Patrick Breheny
See Also
grpreg
Examples
# Fit penalized logistic regression model to birthweight data
data(Birthwt)
X <- Birthwt$X
y <- Birthwt$low
group <- Birthwt$group
fit <- grpreg(X, y, group, penalty="grLasso", family="binomial")
# Coef and predict methods
coef(fit, lambda=.001)
predict(fit, X, type="link", lambda=.07)[1:10]
predict(fit, X, type="response", lambda=.07)[1:10]
predict(fit, X, type="class", lambda=.01)[1:15]
predict(fit, type="vars", lambda=.07)
predict(fit, type="groups", lambda=.07)
predict(fit, type="norm", lambda=.07)
# Coef and predict methods for cross-validation
cvfit <- cv.grpreg(X, y, group, family="binomial", penalty="grMCP")
coef(cvfit)
predict(cvfit, X)[1:10]
predict(cvfit, X, type="response")[1:10]
predict(cvfit, type="groups")