R/phreg.R
resmean.phreg.Rd
Restricted mean for stratified Kaplan-Meier or stratified Cox with martingale standard error. Standard error is computed using linear interpolation between standard errors at jump-times. Plots gives restricted mean at all times. Years lost can be computed based on this and decomposed into years lost for different causes using the cif.yearslost function that is based on integrating the cumulative incidence functions. One particular feature of these functions are that the restricted mean and years-lost are computed for all event times as functions and can be plotted/viewed. When times are given and beyond the last event time withn a strata the curves are extrapolated using the estimates of cumulative incidence.
resmean.phreg(x, times = NULL, covs = NULL, ...)
data(bmt); bmt$time <- bmt$time+runif(408)*0.001
out1 <- phreg(Surv(time,cause!=0)~strata(tcell,platelet),data=bmt)
rm1 <- resmean.phreg(out1,times=10*(1:6))
summary(rm1)
#> strata times rmean se.rmean years.lost
#> tcell.0..platelet.0 0 10 5.863317 0.2565983 4.136683
#> tcell.0..platelet.1 1 10 7.631949 0.3423852 2.368051
#> tcell.1..platelet.0 2 10 7.277585 0.7092826 2.722415
#> tcell.1..platelet.1 3 10 7.670135 0.5624486 2.329865
#> tcell.0..platelet.0.1 0 20 9.888933 0.5393867 10.111067
#> tcell.0..platelet.1.1 1 20 13.506431 0.8000233 6.493569
#> tcell.1..platelet.0.1 2 20 12.103010 1.5545608 7.896990
#> tcell.1..platelet.1.1 3 20 12.787724 1.4675841 7.212276
#> tcell.0..platelet.0.2 0 30 13.602922 0.8315429 16.397078
#> tcell.0..platelet.1.2 1 30 18.901079 1.2693120 11.098921
#> tcell.1..platelet.0.2 2 30 16.191204 2.4006192 13.808796
#> tcell.1..platelet.1.2 3 30 17.766079 2.4422046 12.233921
#> tcell.0..platelet.0.3 0 40 17.159941 1.1235980 22.840059
#> tcell.0..platelet.1.3 1 40 23.880215 1.7372370 16.119785
#> tcell.1..platelet.0.3 2 40 19.549245 3.2030900 20.450755
#> tcell.1..platelet.1.3 3 40 22.433338 3.3838457 17.566662
#> tcell.0..platelet.0.4 0 50 20.482453 1.4110550 29.517547
#> tcell.0..platelet.1.4 1 50 28.324340 2.1962427 21.675660
#> tcell.1..platelet.0.4 2 50 22.746049 4.0537051 27.253951
#> tcell.1..platelet.1.4 3 50 26.115631 4.2306850 23.884369
#> tcell.0..platelet.0.5 0 60 23.741461 1.7038111 36.258539
#> tcell.0..platelet.1.5 1 60 32.761947 2.6868315 27.238053
#> tcell.1..platelet.0.5 2 60 25.942852 4.9475989 34.057148
#> tcell.1..platelet.1.5 3 60 29.671599 5.1599162 30.328401
par(mfrow=c(1,2))
plot(rm1,se=1)
plot(rm1,years.lost=TRUE,se=1)
## years.lost decomposed into causes
drm1 <- cif.yearslost(Event(time,cause)~strata(tcell,platelet),data=bmt,times=10*(1:6))
par(mfrow=c(1,2)); plot(drm1,cause=1,se=1); plot(drm1,cause=2,se=1);
summary(drm1)
#> strata times intF11 intF12 se.intF11 se.intF12
#> tcell.0..platelet.0 0 10 3.117738 1.0189445 0.2487182 0.1703665
#> tcell.0..platelet.1 1 10 1.710922 0.6571287 0.3238386 0.1870565
#> tcell.1..platelet.0 2 10 1.876092 0.8463226 0.6338892 0.4726555
#> tcell.1..platelet.1 3 10 1.358599 0.9712653 0.5303042 0.3617433
#> tcell.0..platelet.0.1 0 20 7.517576 2.5934912 0.5441143 0.3861280
#> tcell.0..platelet.1.1 1 20 4.230951 2.2626177 0.7414079 0.5327582
#> tcell.1..platelet.0.1 2 20 4.568400 3.3285904 1.4876617 1.1718532
#> tcell.1..platelet.1.1 3 20 3.569484 3.6427920 1.3002982 1.1906719
#> tcell.0..platelet.0.2 0 30 12.105138 4.2919401 0.8508110 0.6161454
#> tcell.0..platelet.1.2 1 30 6.884372 4.2145486 1.1740911 0.9057019
#> tcell.1..platelet.0.2 2 30 7.260708 6.5480882 2.3532714 1.9703549
#> tcell.1..platelet.1.2 3 30 5.780368 6.4535527 2.0924957 2.0815299
#> tcell.0..platelet.0.3 0 40 16.718646 6.1214132 1.1626283 0.8509996
#> tcell.0..platelet.1.3 1 40 9.731580 6.3882055 1.6095870 1.2998283
#> tcell.1..platelet.0.3 2 40 9.953015 10.4977393 3.2211897 2.8144211
#> tcell.1..platelet.1.3 3 40 8.302348 9.2643133 2.8717886 2.9840952
#> tcell.0..platelet.0.4 0 50 21.367830 8.1497167 1.4766466 1.0945208
#> tcell.0..platelet.1.4 1 50 12.985930 8.6897296 2.0479371 1.7124157
#> tcell.1..platelet.0.4 2 50 12.645323 14.6086284 4.0899470 3.7302709
#> tcell.1..platelet.1.4 3 50 11.809295 12.0750740 3.6736773 3.8902278
#> tcell.0..platelet.0.5 0 60 26.017014 10.2415244 1.7930410 1.3471514
#> tcell.0..platelet.1.5 1 60 16.246799 10.9912536 2.5105748 2.1389317
#> tcell.1..platelet.0.5 2 60 15.337631 18.7195175 4.9591025 4.6873932
#> tcell.1..platelet.1.5 3 60 15.442567 14.8858347 4.5899540 4.7979069
#> total.years.lost
#> tcell.0..platelet.0 4.136683
#> tcell.0..platelet.1 2.368051
#> tcell.1..platelet.0 2.722415
#> tcell.1..platelet.1 2.329865
#> tcell.0..platelet.0.1 10.111067
#> tcell.0..platelet.1.1 6.493569
#> tcell.1..platelet.0.1 7.896990
#> tcell.1..platelet.1.1 7.212276
#> tcell.0..platelet.0.2 16.397078
#> tcell.0..platelet.1.2 11.098921
#> tcell.1..platelet.0.2 13.808796
#> tcell.1..platelet.1.2 12.233921
#> tcell.0..platelet.0.3 22.840059
#> tcell.0..platelet.1.3 16.119785
#> tcell.1..platelet.0.3 20.450755
#> tcell.1..platelet.1.3 17.566662
#> tcell.0..platelet.0.4 29.517547
#> tcell.0..platelet.1.4 21.675660
#> tcell.1..platelet.0.4 27.253951
#> tcell.1..platelet.1.4 23.884369
#> tcell.0..platelet.0.5 36.258539
#> tcell.0..platelet.1.5 27.238053
#> tcell.1..platelet.0.5 34.057148
#> tcell.1..platelet.1.5 30.328401