predict.rcv.glmnet | R Documentation |
rcv.glmnet
objectCompute fitted values for a model fitted by rcv.glmnet
.
## S3 method for class '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
rcv.glmnet()
, glmnet::predict.cv.glmnet()
,
survival::summary.survfit()
# 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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.