Estimate the marginal causal survival curves for simulating time-to-event data in a discrete manner based on the methods from Daniel et al.(2020).

calculate_statistics(model, trt)

Arguments

model

A fitted coxph model. This should be a coxph event model or censoring model.

trt

Character. Name of the treatment assignment variable.

Value

Two vectors containing the marginal causal survival curves for treatment arms (1 for treatment arm; 0 for control arm/placebo). Each number is the probability of the surviving the time window (t1,t2],... conditional on surviving the prior corresponding window.

Details

If the study period for the original data is divided into discrete windows, defined by the event times in the original data, at time t0 = 0, everyone in the simulated data is still a survivor. S(x) is the estimated survival function. By the end of the window (0,t1], a proportion S(t1) still survives. The conditional probability of surviving the next window, (t1,t2], conditional on surviving the first window, is S(t2)/S(t1), and so on. This function returns the S(t2)/S(t1) in series.

References

Daniel R, Zhang J, Farewell D. Making apples from oranges: Comparing noncollapsible effect estimators and their standard errors after adjustment for different covariate sets. Biom J. 2021;63(3):528-557. doi:10.1002/bimj.201900297

Examples

library(survival)
data("oak")

cox_event <- coxph(Surv(OS, os.status) ~ trt + btmb + pdl1, data = oak)
calculate_statistics(model = cox_event, trt = "trt")
#> $surv_cond0
#>   [1] 1.0000000 1.0000000 0.9978747 0.9978715 0.9957356 0.9957198 0.9957038
#>   [8] 0.9978455 0.9978410 0.9978365 0.9934990 0.9956386 0.9956262 0.9934236
#>  [15] 0.9955952 0.9977894 0.9977800 0.9955512 0.9955314 0.9955112 0.9954946
#>  [22] 0.9977404 0.9977370 0.9954655 0.9977239 0.9954180 1.0000000 0.9976878
#>  [29] 0.9930585 0.9953359 0.9953214 0.9953042 0.9976385 0.9952666 0.9976196
#>  [36] 0.9928508 0.9976011 0.9927787 0.9975770 0.9975735 0.9975672 0.9951293
#>  [43] 0.9951124 0.9950895 0.9975325 0.9975283 0.9925558 0.9950110 0.9949898
#>  [50] 0.9949637 1.0000000 0.9974581 0.9974445 0.9974315 0.9948507 0.9974121
#>  [57] 0.9974034 0.9947946 0.9973851 0.9947628 0.9973686 0.9973638 0.9947184
#>  [64] 0.9946879 0.9973290 0.9973243 0.9973192 0.9973128 0.9946171 0.9972911
#>  [71] 0.9945675 0.9918134 0.9972502 0.9972419 0.9972375 0.9972306 0.9972228
#>  [78] 0.9944306 0.9971989 0.9971941 0.9943767 0.9971772 0.9971721 0.9943268
#>  [85] 0.9971463 0.9971388 0.9885387 0.9971042 0.9941939 0.9941654 0.9941421
#>  [92] 0.9970548 0.9881861 0.9970125 0.9970031 0.9969979 0.9909790 0.9939477
#>  [99] 0.9969607 0.9969547 0.9969490 0.9938807 0.9969244 0.9938364 0.9938046
#> [106] 0.9906554 0.9968532 0.9968466 0.9968394 0.9968292 0.9968090 0.9967905
#> [113] 0.9967811 0.9967705 0.9967602 0.9967398 0.9967285 0.9967223 0.9967161
#> [120] 0.9934137 0.9900689 0.9966521 0.9932866 0.9966245 0.9966126 0.9898109
#> [127] 0.9965661 0.9896687 0.9895816 0.9929859 0.9964693 0.9964620 0.9964493
#> [134] 0.9964336 0.9857334 0.9963860 0.9963776 0.9890968 0.9926518 0.9926039
#> [141] 0.9962831 0.9925393 0.9962442 1.0000000 0.9924560 0.9923906 0.9961660
#> [148] 0.9923088 1.0000000 0.9961167 0.9961013 0.9960873 1.0000000 0.9960611
#> [155] 0.9920923 0.9960183 0.9920224 0.9959893 0.9959744 0.9959645 0.9918992
#> [162] 0.9959157 0.9958979 0.9958875 0.9917547 0.9916834 0.9916206 0.9957808
#> [169] 0.9957690 0.9872428 0.9956915 0.9956726 0.9956551 0.9956380 0.9956205
#> [176] 0.9912054 0.9955743 0.9910801 0.9910170 0.9954727 0.9954511 0.9954294
#> [183] 0.9954078 0.9907924 0.9953610 0.9906970 0.9953103 0.9952883 0.9952642
#> [190] 0.9904826 0.9951967 0.9903723 0.9951531 0.9951302 0.9902183 0.9950639
#> [197] 0.9900967 0.9949998 0.9949841 0.9949687 0.9949457 0.9847774 0.9948546
#> [204] 0.9948392 0.9948108 0.9947862 0.9947296 0.9947036 0.9946783 0.9946597
#> [211] 0.9946306 0.9946141 0.9891723 0.9945284 0.9944982 0.9889320 0.9888085
#> [218] 1.0000000 0.9943250 0.9943065 0.9942846 0.9942476 0.9942177 0.9884065
#> [225] 0.9941573 0.9941119 0.9940783 0.9940555 0.9940306 0.9939913 0.9939539
#> [232] 0.9939210 0.9938970 0.9938730 0.9938339 0.9937937 0.9937479 0.9937055
#> [239] 0.9810516 0.9935905 0.9935533 0.9935285 0.9934793 0.9934541 0.9868340
#> [246] 0.9933356 0.9933049 0.9932777 0.9932464 0.9931984 0.9931509 0.9862557
#> [253] 0.9930578 0.9930068 0.9859423 0.9928507 0.9856228 0.9926935 0.9926515
#> [260] 0.9926198 0.9925876 0.9925557 0.9925188 0.9849556 0.9923967 0.9923582
#> [267] 0.9923022 0.9922628 0.9843958 0.9920736 0.9920080 0.9919604 0.9919235
#> [274] 0.9918627 0.9917924 0.9917479 0.9916854 0.9916438 0.9915809 0.9915165
#> [281] 0.9914725 0.9914305 0.9913874 0.9913094 0.9912645 0.9912114 0.9911404
#> [288] 0.9910885 0.9910426 0.9819550 1.0000000 1.0000000 1.0000000 1.0000000
#> [295] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [302] 1.0000000 0.9894353 1.0000000 1.0000000 1.0000000 0.9889847 1.0000000
#> [309] 0.9884840 1.0000000 0.9882824 0.9764275 0.9753052 1.0000000 1.0000000
#> [316] 0.9867132 0.9863104 1.0000000 1.0000000 1.0000000 1.0000000 0.9850011
#> [323] 1.0000000 1.0000000 1.0000000 1.0000000 0.9837943 1.0000000 1.0000000
#> [330] 1.0000000 1.0000000 1.0000000 0.9816534 1.0000000 1.0000000 1.0000000
#> [337] 0.9802719 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [344] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.9753036 0.9748806
#> [351] 1.0000000 0.9736401 1.0000000 1.0000000 0.9714089 1.0000000 1.0000000
#> [358] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [365] 0.9607817 1.0000000 1.0000000 0.9548850 1.0000000 1.0000000 1.0000000
#> [372] 1.0000000 0.9465078 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [379] 1.0000000 0.9205256 0.9052758 1.0000000 1.0000000 1.0000000 1.0000000
#> [386] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.6410363
#> [393] 1.0000000 1.0000000
#> 
#> $surv_cond1
#>   [1] 1.0000000 1.0000000 0.9986476 0.9986455 0.9972853 0.9972752 0.9972649
#>   [8] 0.9986289 0.9986261 0.9986232 0.9958595 0.9972233 0.9972154 0.9958113
#>  [15] 0.9971955 0.9985931 0.9985871 0.9971674 0.9971548 0.9971419 0.9971313
#>  [22] 0.9985618 0.9985596 0.9971127 0.9985513 0.9970823 1.0000000 0.9985283
#>  [29] 0.9955779 0.9970299 0.9970206 0.9970096 0.9984968 0.9969856 0.9984847
#>  [36] 0.9954450 0.9984729 0.9953989 0.9984575 0.9984553 0.9984513 0.9968978
#>  [43] 0.9968871 0.9968724 0.9984291 0.9984264 0.9952563 0.9968222 0.9968087
#>  [50] 0.9967920 1.0000000 0.9983816 0.9983729 0.9983646 0.9967198 0.9983522
#>  [57] 0.9983467 0.9966840 0.9983350 0.9966636 0.9983244 0.9983214 0.9966352
#>  [64] 0.9966157 0.9982992 0.9982961 0.9982929 0.9982888 0.9965704 0.9982749
#>  [71] 0.9965388 0.9947813 0.9982488 0.9982435 0.9982407 0.9982363 0.9982313
#>  [78] 0.9964512 0.9982160 0.9982130 0.9964167 0.9982022 0.9981989 0.9963847
#>  [85] 0.9981824 0.9981776 0.9926883 0.9981555 0.9962998 0.9962815 0.9962666
#>  [92] 0.9981239 0.9924623 0.9980969 0.9980909 0.9980875 0.9942469 0.9961422
#>  [99] 0.9980638 0.9980599 0.9980563 0.9960993 0.9980405 0.9960709 0.9960506
#> [106] 0.9940395 0.9979950 0.9979908 0.9979862 0.9979797 0.9979668 0.9979550
#> [113] 0.9979490 0.9979422 0.9979356 0.9979226 0.9979154 0.9979114 0.9979074
#> [120] 0.9958005 0.9936638 0.9978665 0.9957191 0.9978489 0.9978412 0.9934985
#> [127] 0.9978115 0.9934074 0.9933515 0.9955267 0.9977497 0.9977450 0.9977369
#> [134] 0.9977268 0.9908886 0.9976964 0.9976910 0.9930406 0.9953127 0.9952820
#> [141] 0.9976305 0.9952406 0.9976056 1.0000000 0.9951873 0.9951454 0.9975557
#> [148] 0.9950930 1.0000000 0.9975241 0.9975143 0.9975053 1.0000000 0.9974886
#> [155] 0.9949544 0.9974612 0.9949096 0.9974427 0.9974331 0.9974268 0.9948306
#> [162] 0.9973956 0.9973842 0.9973775 0.9947380 0.9946923 0.9946521 0.9973092
#> [169] 0.9973016 0.9918512 0.9972521 0.9972400 0.9972288 0.9972179 0.9972067
#> [176] 0.9943860 0.9971771 0.9943057 0.9942652 0.9971120 0.9970982 0.9970844
#> [183] 0.9970705 0.9941213 0.9970405 0.9940601 0.9970081 0.9969940 0.9969786
#> [190] 0.9939226 0.9969354 0.9938518 0.9969075 0.9968928 0.9937530 0.9968504
#> [197] 0.9936750 0.9968093 0.9967993 0.9967893 0.9967746 0.9902675 0.9967163
#> [204] 0.9967064 0.9966882 0.9966725 0.9966363 0.9966196 0.9966034 0.9965915
#> [211] 0.9965729 0.9965623 0.9930819 0.9965074 0.9964880 0.9929277 0.9928485
#> [218] 1.0000000 0.9963771 0.9963653 0.9963512 0.9963276 0.9963084 0.9925904
#> [225] 0.9962696 0.9962406 0.9962190 0.9962045 0.9961885 0.9961633 0.9961393
#> [232] 0.9961182 0.9961029 0.9960875 0.9960624 0.9960367 0.9960073 0.9959802
#> [239] 0.9878707 0.9959064 0.9958826 0.9958667 0.9958352 0.9958190 0.9915802
#> [246] 0.9957430 0.9957233 0.9957059 0.9956858 0.9956550 0.9956246 0.9912084
#> [253] 0.9955648 0.9955321 0.9910069 0.9954320 0.9908015 0.9953312 0.9953043
#> [260] 0.9952839 0.9952632 0.9952428 0.9952191 0.9903722 0.9951407 0.9951160
#> [267] 0.9950800 0.9950548 0.9900120 0.9949334 0.9948913 0.9948608 0.9948370
#> [274] 0.9947980 0.9947530 0.9947244 0.9946842 0.9946575 0.9946172 0.9945758
#> [281] 0.9945476 0.9945206 0.9944929 0.9944428 0.9944139 0.9943798 0.9943342
#> [288] 0.9943009 0.9942714 0.9884400 1.0000000 1.0000000 1.0000000 1.0000000
#> [295] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [302] 1.0000000 0.9932411 1.0000000 1.0000000 1.0000000 0.9929520 1.0000000
#> [309] 0.9926309 1.0000000 0.9925014 0.9848816 0.9841577 1.0000000 1.0000000
#> [316] 0.9914937 0.9912349 1.0000000 1.0000000 1.0000000 1.0000000 0.9903940
#> [323] 1.0000000 1.0000000 1.0000000 1.0000000 0.9896185 1.0000000 1.0000000
#> [330] 1.0000000 1.0000000 1.0000000 0.9882421 1.0000000 1.0000000 1.0000000
#> [337] 0.9873530 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [344] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.9841528 0.9838793
#> [351] 1.0000000 0.9830785 1.0000000 1.0000000 0.9816376 1.0000000 1.0000000
#> [358] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [365] 0.9747610 1.0000000 1.0000000 0.9709319 1.0000000 1.0000000 1.0000000
#> [372] 1.0000000 0.9654769 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [379] 1.0000000 0.9484481 0.9383648 1.0000000 1.0000000 1.0000000 1.0000000
#> [386] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.7524613
#> [393] 1.0000000 1.0000000
#>