rcv.glmnet
objectpredict.rcv.glmnet.Rd
Compute fitted values for a model fitted by rcv.glmnet
.
# S3 method for rcv.glmnet predict( object, newx, s = c("lambda.1se", "lambda.min"), type = c("link", "response", "coefficients", "nonzero", "class", "survival"), times, ... )
object |
|
---|---|
newx |
|
s |
|
type |
|
times |
|
... | further arguments passed to |
The object returned depends on the ... arguments.
See glmnet::predict.cv.glmnet()
for details. For type = "survival"
the
returned value is a matrix
with one row per times
element and one column
for each row in newx
.
Sebastian Gibb
# Example adapted from ?"glmnet::cv.glmnet" set.seed(10101) n <- 500 p <- 30 nzc <- trunc(p / 10) x <- matrix(rnorm(n * p), n, p) beta <- rnorm(nzc) fx <- x[, seq(nzc)] %*% beta / 3 hx <- exp(fx) ty <- rexp(n, hx) tcens <- rbinom(n = n, prob = 0.3, size = 1) # censoring indicator # y <- Surv(ty, 1-tcens) with library("survival") y <- cbind(time = ty, status = 1 - tcens) # nrepcv should usually be higher but to keep the runtime of the example low # we choose 2 here rcvob <- rcv.glmnet(x, y, family = "cox", nrepcv = 2, nfolds = 3) predict( rcvob, newx = x[1:5,], x = x, y = survival::Surv(y[, "time"], y[, "status"]), type = "survival", times = c(0, 7), s = "lambda.1se" )#> 1 2 3 4 5 #> [1,] 1.0000000 1.00000000 1.000000000 1.000000000 1.00000000 #> [2,] 0.1447802 0.04872118 0.001133545 0.006851513 0.01952228