Skip to contents

Predict overall survival probability at certain time points from fitted Cox models.

Usage

# S3 method for hdnom.model
predict(object, x, y, newx, pred.at, ...)

Arguments

object

Model object.

x

Data matrix used to fit the model.

y

Response matrix made with Surv.

newx

Matrix (with named columns) of new values for x at which predictions are to be made.

pred.at

Time point at which prediction should take place.

...

Other parameters (not used).

Value

A nrow(newx) x length(pred.at) matrix containing overall survival probablity.

Examples

data("smart")
x <- as.matrix(smart[, -c(1, 2)])
time <- smart$TEVENT
event <- smart$EVENT
y <- survival::Surv(time, event)

fit <- fit_lasso(x, y, nfolds = 5, rule = "lambda.1se", seed = 11)
predict(fit, x, y, newx = x[101:105, ], pred.at = 1:10 * 365)
#>            365       730      1095      1460      1825      2190      2555
#> [1,] 0.9495796 0.9230039 0.8917647 0.8613490 0.8224649 0.7908937 0.7511011
#> [2,] 0.9600830 0.9388629 0.9137521 0.8891229 0.8573649 0.8313443 0.7982304
#> [3,] 0.9711410 0.9556623 0.9372179 0.9189884 0.8952713 0.8756544 0.8504380
#> [4,] 0.9370250 0.9041739 0.8658684 0.8289029 0.7821335 0.7445751 0.6977844
#> [5,] 0.9656619 0.9473253 0.9255501 0.9041098 0.8763384 0.8534751 0.8242311
#>           2920      3285      3650
#> [1,] 0.7127632 0.6593639 0.6593639
#> [2,] 0.7659723 0.7204170 0.7204170
#> [3,] 0.8255890 0.7899889 0.7899889
#> [4,] 0.6533031 0.5923716 0.5923716
#> [5,] 0.7955765 0.7548149 0.7548149