Learn R Programming

grpSLOPE (version 0.3.3)

predict.grpSLOPE: Obtain predictions

Description

Obtain predictions from a grpSLOPE model on new data

Usage

# S3 method for grpSLOPE
predict(object, newdata, ...)

Value

A vector of length nrow(newdata) containing the resulting predictions.

Arguments

object

A grpSLOPE object

newdata

Predictor variables arranged in a matrix

...

Potentially further arguments passed to and from methods

Details

Note that newdata must contain the same predictor variables as columns in the same order as the design matrix X that was used for the grpSLOPE model fit.

Examples

Run this code
set.seed(1)
A   <- matrix(rnorm(100^2), 100, 100)
grp <- rep(rep(1:20), each = 5)
b   <- c(rep(1, 20), rep(0, 80))
y   <- A %*% b + rnorm(10) 
result <- grpSLOPE(X = A, y = y, group = grp, fdr = 0.1)
newdata <- matrix(rnorm(800), 8, 100)
# group SLOPE predictions:
predict(result, newdata)
# [1] -5.283385 -6.313938 -3.173068  1.901488  9.796677 -0.144516 -0.611164 -5.167620
# true mean values:
as.vector(newdata %*% b)
# [1] -5.0937160 -6.5814111 -3.5776124  2.7877449 11.0668777  1.0253236 -0.4261076 -4.8622940

Run the code above in your browser using DataLab