predict.cv.grpreg | R Documentation |
grpreg
objectSimilar to other predict methods, this function returns predictions from a
fitted "grpreg"
object.
## 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, ...)
## 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, ...)
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: |
... |
Not used. |
drop |
By default, if a single value of |
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.
The object returned depends on type.
Patrick Breheny
grpreg
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.