Learn R Programming

grpregOverlap (version 2.2-0)

predict.grpregOverlap: Model predictions based on a fitted object

Description

Similar to other predict methods, this function returns predictions from a fitted "grpregOverlap" object.

Usage

"predict"(object, X, type = c("link", "response", "class", "coefficients", "vars", "groups", "nvars", "ngroups", "norm"), latent = FALSE, lambda, which = 1:length(object$lambda), ...) "predict"(object, X, type = c("link", "response", "class", "coefficients", "vars", "groups", "nvars", "ngroups", "norm"), latent = FALSE, lambda = object$lambda.min, which=object$min, ...) "coef"(object, lambda, latent = FALSE, which=1:length(object$lambda), drop=TRUE, ...) "coef"(object, latent = FALSE, lambda = object$lambda.min, which = object$min, ...)

Arguments

object
A fitted "grpregOverlap" or "cv.grpregOverlap" model object.
X
Matrix of values at which predictions are to be made. Not used for type="coefficients".
type
Type of prediction: "link" returns the linear predictors; "response" gives the fitted values; "class" returns the binomial outcome with the highest probability; "coefficients" returns the coefficients; "vars" returns the indices for the nonzero coefficients; "groups" returns the indices for the groups with at least one nonzero coefficient; "nvars" returns the number of nonzero coefficients; "ngroups" returns the number of groups with at least one nonzero coefficient; "norm" returns the L2 norm of the coefficients in each group.
latent
Should return prediction values at the latent level? Default is FALSE. The option latent = TRUE is meaningful only if type is "coefficients", "vars", "nvars", or "norm" since there are no latent information for other types. Otherwise, a note message will be printed; If type = "norm", this argument is overwritten to be 'TRUE' since the L2 norms are from latent coefficients.
lambda
Values of the regularization parameter lambda at which predictions are requested. For values of lambda not in the sequence of fitted models, linear interpolation is used.
which
Indices of the penalty parameter lambda at which predictions are required. By default, all indices are returned. If lambda is specified, this will override which.
drop
Drop the matrix to be a vector.
...
Not used.

Value

The object returned depends on the specification on type and latent.

Details

coef and predict methods are provided for "cv.grpregOverlap" options as a convenience. They simply call coef.grpregOverlap and predict.grpregOverlap with lambda set to the value that minimizes the cross-validation error.

See Also

grpregOverlap

Examples

Run this code
data(pathway.dat)
X <- pathway.dat$expression
group <- pathway.dat$pathways
y <- pathway.dat$mutation
fit <- grpregOverlap(X, y, group, penalty = 'grLasso', family = 'binomial')
head(predict(fit, type = 'ngroups', lambda = 0.01))
head(predict(fit, type = 'nvars', lambda = 0.01))
head(predict(fit, type = 'vars', latent = TRUE, lambda = 0.01))
head(predict(fit, type = 'groups', latent = TRUE, lambda = 0.01)) # A note printed.
head(predict(fit, X, type="class", lambda=.01))
head(predict(fit, X, type = "coefficients", lambda = 0.01))
head(predict(fit, type="norm", lambda=.01))

## Not run: 
# cvfit <- cv.grpregOverlap(X, y, group, penalty = 'grLasso', family = 'binomial')
# head(coef(cvfit))
# predict(cvfit, X, type='response')
# predict(cvfit, X, type = 'link')
# predict(cvfit, X, type = 'class')
# ## End(Not run)

Run the code above in your browser using DataLab