Closed zou-ims closed 8 months ago
There is an issue in the current CRAN version with the use of weights in relative survival models. This is fixed in the development version, so that the weighted log likelihood is now a weighted sum of individual-specific log likelihoods. Previously the rationale for how weights were included here was unclear (see changes in commit https://github.com/chjackson/flexsurv/commit/3d6c0947d2aa8b6bc24c11aa2c97acef97419e7d#diff-0d29a958f7b0e1d3fa4d91f269b6afb95db08fd35cc46f9988096fa6ec1b1cbf)
Note also the predictions from fitted relative survival models in flexsurv refer to the relative survival (or excess hazard) rather than the overall population survival.
Does the development version give the results you expect?
Yes, using the development version, the results look reasonable now. Thank you.
Please see my code below. I was hoping to see model1 and model2 to be quite different, but they are almost identical.
From the plot, for model1 at time=15, the observed and estimated survivals are both about 0.17.
With bhazard provided in my data, the expected survival from the general population at time=15 is (1-0.01)(1.02)...*(1-0.15)=0.28. So I was hoping to see the observed and estimated (relative) survivals at time=15 from model2 to be 0.17/0.28.
Thanks.
library(flexsurv) data<-data.frame( time=c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15), death=c(1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0), weight=c(18,3,26,2,29,33,29,33,30,29,29,27,28,25,26,23,24,20,21,17,18,16,16,13,13,11,10,9,8,7), bhazard=c(0.01,0.01,0.02,0.02,0.03,0.03,0.04,0.04,0.05,0.05,0.06,0.06,0.07,0.07,0.08,0.08, 0.09,0.09,0.1,0.1,0.11,0.11,0.12,0.12,0.13,0.13,0.14,0.14,0.15,0.15)) model1<-flexsurvreg(Surv(time,death)~1,data=data,weights=weight,dist="weibull") model2<-flexsurvreg(Surv(time,death)~1,data=data,weights=weight,bhazard=bhazard,dist="weibull") coef(model1) coef(model2) plot(model1) plot(model2)