predict.CauseSpecificCox: Predicting Absolute Risk from Cause-Specific Cox Models

Description Usage Arguments Details Author(s) References See Also Examples

View source: R/predict.CauseSpecificCox.R

Description

Apply formula to combine two or more Cox models into absolute risk (cumulative incidence function).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## S3 method for class 'CauseSpecificCox'
predict(
  object,
  newdata,
  times,
  cause,
  type = "absRisk",
  landmark = NA,
  keep.times = 1L,
  keep.newdata = 1L,
  keep.strata = 1L,
  se = FALSE,
  band = FALSE,
  iid = FALSE,
  confint = (se + band) > 0,
  average.iid = FALSE,
  product.limit = TRUE,
  store.iid = "full",
  diag = FALSE,
  max.time = NULL,
  ...
)

Arguments

object

The fitted cause specific Cox model

newdata

[data.frame or data.table] Contain the values of the predictor variables defining subject specific predictions relative to each cause. Should have the same structure as the data set used to fit the object.

times

[numeric vector] Time points at which to return the estimated absolute risk.

cause

[integer/character] Identifies the cause of interest among the competing events.

type

[character] Can be changed to "survival" if the event free survival should be output instead of the absolute risk.

landmark

[integer] The starting time for the computation of the cumulative risk.

keep.times

[logical] If TRUE add the evaluation times to the output.

keep.newdata

[logical] If TRUE add the value of the covariates used to make the prediction in the output list.

keep.strata

[logical] If TRUE add the value of the strata used to make the prediction in the output list.

se

[logical] If TRUE compute and add the standard errors to the output.

band

[logical] If TRUE compute and add the quantiles for the confidence bands to the output.

iid

[logical] If TRUE compute and add the influence function to the output.

confint

[logical] If TRUE compute and add the confidence intervals/bands to the output. They are computed applying the confint function to the output.

average.iid

[logical]. If TRUE add the average of the influence function over newdata to the output.

product.limit

[logical]. If TRUE the survival is computed using the product limit estimator. Otherwise the exponential approximation is used (i.e. exp(-cumulative hazard)).

store.iid

[character] Implementation used to estimate the influence function and the standard error. Can be "full" or "minimal".

diag

[logical] when FALSE the absolute risk/survival for all observations at all times is computed, otherwise it is only computed for the i-th observation at the i-th time.

max.time

[numeric] maximum time of the response of the fitted data. Only relevant if model response element has been removed

...

not used.

Details

This function computes the absolute risk as given by formula 2 of (Ozenne et al., 2017). Confidence intervals and confidence bands can be computed using a first order von Mises expansion. See the section "Construction of the confidence intervals" in (Ozenne et al., 2017).

A detailed explanation about the meaning of the argument store.iid can be found in (Ozenne et al., 2017) Appendix B "Saving the influence functions".

Note: for Cox regression models with time varying covariates it does not make sense to use this function, because the predicted risk has to be a measurable function of the data available at the time origin.

The iid decomposition is output using an array containing the value of the influence of each subject used to fit the object (dim 1), for each subject in newdata (dim 3), and each time (dim 2).

Author(s)

Brice Ozenne broz@sund.ku.dk, Thomas A. Gerds tag@biostat.ku.dk

References

Brice Ozenne, Anne Lyngholm Sorensen, Thomas Scheike, Christian Torp-Pedersen and Thomas Alexander Gerds. riskRegression: Predicting the Risk of an Event using Cox Regression Models. The R Journal (2017) 9:2, pages 440-460.

See Also

confint.predictCSC to compute confidence intervals/bands. autoplot.predictCSC to display the predictions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
library(survival)
library(prodlim)
#### generate data ####
set.seed(5)
d <- sampleData(80,outcome="comp") ## training dataset
nd <- sampleData(4,outcome="comp") ## validation dataset
d$time <- round(d$time,1) ## create tied events
ttt <- sort(sample(x = unique(d$time), size = 10))

## estimate a CSC model based on the coxph function
CSC.fit <- CSC(Hist(time,event)~ X3+X8, data=d, method = "breslow")

## compute the absolute risk of cause 1, in the validation dataset
## at time 1:10
CSC.risk <-  predict(CSC.fit, newdata=nd, times=1:10, cause=1)
CSC.risk

## compute absolute risks with CI for cause 2
## (without displaying the value of the covariates)
predict(CSC.fit,newdata=nd,times=1:10,cause=2,se=TRUE,
        keep.newdata = FALSE)

## other example
library(survival)
CSC.fit.s <- CSC(list(Hist(time,event)~ strata(X1)+X2+X9,
 Hist(time,event)~ X2+strata(X4)+X8+X7),data=d, method = "breslow")
predict(CSC.fit.s,cause=1,times=ttt,se=1L) ## note: absRisk>1 due to small number of observations

## using the cph function instead of coxph
CSC.cph <- CSC(Hist(time,event)~ X1+X2,data=d, method = "breslow", fitter = "cph")#'
predict(CSC.cph, newdata = d, cause = 2, times = ttt)

## landmark analysis
T0 <- 1
predCSC.afterT0 <- predict(CSC.fit, newdata = d, cause = 2, times = ttt[ttt>T0], landmark = T0)
predCSC.afterT0

Example output

riskRegression version 2020.02.05
    observation X3      X8 times absRisk
 1:           1  1 -1.5612     1  0.0969
 2:           2  1 -0.7577     1  0.0948
 3:           3  0  1.5421     1  0.0810
 4:           4  0 -0.0647     1  0.0847
 5:           1  1 -1.5612     2  0.2667
 6:           2  1 -0.7577     2  0.2617
 7:           3  0  1.5421     2  0.2270
 8:           4  0 -0.0647     2  0.2359
 9:           1  1 -1.5612     3  0.3574
10:           2  1 -0.7577     3  0.3520
11:           3  0  1.5421     3  0.3085
12:           4  0 -0.0647     3  0.3186
13:           1  1 -1.5612     4  0.4220
14:           2  1 -0.7577     4  0.4172
15:           3  0  1.5421     4  0.3689
16:           4  0 -0.0647     4  0.3784
17:           1  1 -1.5612     5  0.4572
18:           2  1 -0.7577     5  0.4535
19:           3  0  1.5421     5  0.4036
20:           4  0 -0.0647     5  0.4113
21:           1  1 -1.5612     6  0.4765
22:           2  1 -0.7577     6  0.4738
23:           3  0  1.5421     6  0.4235
24:           4  0 -0.0647     6  0.4295
25:           1  1 -1.5612     7  0.5401
26:           2  1 -0.7577     7  0.5428
27:           3  0  1.5421     7  0.4934
28:           4  0 -0.0647     7  0.4903
29:           1  1 -1.5612     8  0.5625
30:           2  1 -0.7577     8  0.5671
31:           3  0  1.5421     8  0.5185
32:           4  0 -0.0647     8  0.5120
33:           1  1 -1.5612     9  0.5625
34:           2  1 -0.7577     9  0.5671
35:           3  0  1.5421     9  0.5185
36:           4  0 -0.0647     9  0.5120
37:           1  1 -1.5612    10  0.5967
38:           2  1 -0.7577    10  0.6073
39:           3  0  1.5421    10  0.5629
40:           4  0 -0.0647    10  0.5456
    observation X3      X8 times absRisk
    observation times absRisk absRisk.se absRisk.lower absRisk.upper
 1:           1     1 0.00000     0.0000      0.000000        0.0000
 2:           2     1 0.00000     0.0000      0.000000        0.0000
 3:           3     1 0.00000     0.0000      0.000000        0.0000
 4:           4     1 0.00000     0.0000      0.000000        0.0000
 5:           1     2 0.01409     0.0155      0.000855        0.0764
 6:           2     2 0.01107     0.0113      0.000904        0.0554
 7:           3     2 0.00907     0.0111      0.000397        0.0593
 8:           4     2 0.01470     0.0153      0.001073        0.0739
 9:           1     3 0.06024     0.0455      0.008579        0.1904
10:           2     3 0.04785     0.0258      0.013482        0.1170
11:           3     3 0.04038     0.0297      0.006543        0.1290
12:           4     3 0.06422     0.0379      0.015235        0.1651
13:           1     4 0.06024     0.0455      0.008579        0.1904
14:           2     4 0.04785     0.0258      0.013482        0.1170
15:           3     4 0.04038     0.0297      0.006543        0.1290
16:           4     4 0.06422     0.0379      0.015235        0.1651
17:           1     5 0.14687     0.0920      0.026324        0.3636
18:           2     5 0.11898     0.0639      0.030524        0.2729
19:           3     5 0.10403     0.0816      0.011531        0.3174
20:           4     5 0.15961     0.0563      0.068873        0.2841
21:           1     6 0.18485     0.1198      0.027826        0.4513
22:           2     6 0.15128     0.0838      0.034903        0.3454
23:           3     6 0.13399     0.0953      0.017909        0.3663
24:           4     6 0.20173     0.0599      0.100005        0.3286
25:           1     7 0.18485     0.1198      0.027826        0.4513
26:           2     7 0.15128     0.0838      0.034903        0.3454
27:           3     7 0.13399     0.0953      0.017909        0.3663
28:           4     7 0.20173     0.0599      0.100005        0.3286
29:           1     8 0.20546     0.1285      0.032271        0.4822
30:           2     8 0.16927     0.0915      0.039727        0.3760
31:           3     8 0.15172     0.1087      0.018870        0.4083
32:           4     8 0.22556     0.0641      0.114794        0.3590
33:           1     9 0.25516     0.1524      0.040038        0.5600
34:           2     9 0.21404     0.1110      0.050731        0.4506
35:           3     9 0.19687     0.1332      0.025363        0.4873
36:           4     9 0.28284     0.0732      0.151571        0.4294
37:           1    10 0.25516     0.1524      0.040038        0.5600
38:           2    10 0.21404     0.1110      0.050731        0.4506
39:           3    10 0.19687     0.1332      0.025363        0.4873
40:           4    10 0.28284     0.0732      0.151571        0.4294
    observation times absRisk absRisk.se absRisk.lower absRisk.upper
     observation X2     X9       X8   X7 times    strata absRisk absRisk.se
  1:           1  0 -0.836 -0.39410 57.5   0.6 X1=0 X4=1  0.0871     0.0417
  2:           2  0  2.030 -1.51024 56.2   0.6 X1=0 X4=0  0.0170     0.0102
  3:           3  0  0.429  0.00599 77.0   0.6 X1=0 X4=1  0.0426     0.0202
  4:           4  0  1.064  0.85501 57.7   0.6 X1=0 X4=1  0.0297     0.0151
  5:           5  1 -0.606  0.72985 68.6   0.6 X1=0 X4=0  0.1319     0.0577
 ---                                                                       
796:          76  0  0.477  0.36861 63.9  11.8 X1=0 X4=0  0.4500     0.0877
797:          77  0  1.308  0.64851 58.3  11.8 X1=0 X4=0  0.3206     0.0853
798:          78  0  1.806 -0.43983 59.9  11.8 X1=0 X4=0  0.2397     0.0794
799:          79  1  1.035 -0.86642 59.3  11.8 X1=0 X4=0  0.4509     0.1609
800:          80  0  0.517  0.86530 59.7  11.8 X1=1 X4=0      NA         NA
     absRisk.lower absRisk.upper
  1:       0.02773        0.1899
  2:       0.00441        0.0470
  3:       0.01445        0.0954
  4:       0.00939        0.0706
  5:       0.04538        0.2654
 ---                            
796:       0.27569        0.6096
797:       0.16536        0.4872
798:       0.10535        0.4039
799:       0.14713        0.7182
800:            NA            NA
     observation X1 X2 times absRisk
  1:           1  0  0   0.6   0.000
  2:           2  0  0   0.6   0.000
  3:           3  0  0   0.6   0.000
  4:           4  0  0   0.6   0.000
  5:           5  0  1   0.6   0.000
 ---                                
796:          76  0  0  11.8   0.499
797:          77  0  0  11.8   0.499
798:          78  0  0  11.8   0.499
799:          79  0  1  11.8   0.340
800:          80  1  0  11.8   0.242
     observation X3       X8 times absRisk
  1:           1  0 -0.39410   2.9  0.0761
  2:           2  1 -1.51024   2.9  0.0647
  3:           3  1  0.00599   2.9  0.0417
  4:           4  0  0.85501   2.9  0.0530
  5:           5  0  0.72985   2.9  0.0550
 ---                                      
636:          76  1  0.36861  11.8  0.3184
637:          77  0  0.64851  11.8  0.4514
638:          78  1 -0.43983  11.8  0.3727
639:          79  1 -0.86642  11.8  0.4022
640:          80  0  0.86530  11.8  0.4346

riskRegression documentation built on Jan. 13, 2021, 11:12 a.m.