R/predict.prodlim.R
predict.prodlim.Rd
Evaluation of estimated survival or event probabilities at given times and covariate constellations.
A fitted object of class "prodlim".
Vector of times at which to return the estimated probabilities (survival or absolute event risks).
A data frame with the same variable names as those that appear on the right hand side of the 'prodlim' formula. If there are covariates this argument is required.
Integer specifying the sorting of the output: `0' sort by time and newdata; `1' only by time; `2' no sorting at all
Choice between "surv","risk","cuminc","list":
"surv": predict survival probabilities only survival models
"risk"/"cuminc": predict absolute risk, i.e., cumulative incidence function.
"list": find the indices corresponding to times and newdata. See value.
Defaults to "surv" for two-state models and to "risk" for competing risk models.
Only for type=="surv"
and type=="risk"
. Can
either be "list" or "matrix". For "matrix" the predicted probabilities will
be returned in matrix form.
Logical. If TRUE and mode=="matrix"
the matrix with
predicted probabilities will have a column for each time and a row for each
newdata. Only when object$covariate.type>1
and more than one time is
given.
Character (other classes are converted with as.character
).
The cause for predicting the absolute risk of an event, i.e., the cause-specific cumulative
incidence function, in competing risk models. At any time after time zero this is the absolute risk of
an event of type cause
to occur between time zero and times
.
Only for compatibility reasons.
type=="surv"
A list or a matrix with survival probabilities
for all times and all newdata.
type=="risk"
or type=="cuminc"
A list or a matrix with cumulative incidences for all
times and all newdata.
type=="list"
A list with the following components:
The argument times
carried forward
The relevant part of the argument newdata
.
A list with the following components
time
: Where to find values corresponding to the requested times
strata
: Where to find values corresponding to the values of the
variables in newdata. Together time and strata show where to find the
predicted probabilities.
a list with the following
components: time
: The length of times
strata
: The
number of rows in newdata
names.strata
: Labels for the
covariate values.
Predicted (survival) probabilities are returned that can be plotted, summarized and used for inverse of probability of censoring weighting.
dat <- SimSurv(400)
fit <- prodlim(Hist(time,status)~1,data=dat)
## predict the survival probs at selected times
predict(fit,times=c(3,5,10))
#> [1] 0.7823540 0.6134853 0.2906672
## NA is returned when the time point is beyond the
## range of definition of the Kaplan-Meier estimator:
predict(fit,times=c(-1,0,10,100,1000,10000))
#> [1] 1.0000000 1.0000000 0.2906672 NA NA NA
## when there are strata, newdata is required
## or neighborhoods (i.e. overlapping strata)
mfit <- prodlim(Hist(time,status)~X1+X2,data=dat)
predict(mfit,times=c(-1,0,10,100,1000,10000),newdata=dat[18:21,])
#> $`X1=0, X2= 3.09`
#> [1] 1.00000000 1.00000000 0.04270648 NA NA NA
#>
#> $`X1=0, X2= 1.00`
#> [1] 1.0000000 1.0000000 0.1070347 NA NA NA
#>
#> $`X1=1, X2=-0.47`
#> [1] 1.0000000 1.0000000 0.3101857 NA NA NA
#>
#> $`X1=0, X2= 0.50`
#> [1] 1.0000000 1.0000000 0.2267839 NA NA NA
#>
## this can be requested in matrix form
predict(mfit,times=c(-1,0,10,100,1000,10000),newdata=dat[18:21,],mode="matrix")
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> X1=0, X2= 3.09 1 1 0.04270648 NA NA NA
#> X1=0, X2= 1.00 1 1 0.10703473 NA NA NA
#> X1=1, X2=-0.47 1 1 0.31018568 NA NA NA
#> X1=0, X2= 0.50 1 1 0.22678391 NA NA NA
## and even transposed
predict(mfit,times=c(-1,0,10,100,1000,10000),newdata=dat[18:21,],mode="matrix",bytime=TRUE)
#> [,1] [,2] [,3] [,4]
#> t=-1 1.00000000 1.0000000 1.0000000 1.0000000
#> t=0 1.00000000 1.0000000 1.0000000 1.0000000
#> t=10 0.04270648 0.1070347 0.3101857 0.2267839
#> t=100 NA NA NA NA
#> t=1000 NA NA NA NA
#> t=10000 NA NA NA NA