Reputation: 11
I have a survival kapplan-Meier curves and I want to extrapolate different model curves (e.g. Weibull, Gompertz,...) using the flexsurv package. I have succeed to do the extrapolation but I do not find the solution to create a matrix of the extrapolation plot.
library(survival)
library(flexsurv)
kmsurvival <- survfit (Surv(time, status) ~ 1, data=lung)
summary(kmsurvival)
plot(kmsurvival, xlab="Time", ylab="Survival probability")
Gompertz<-flexsurvreg(Surv(time, status)~1, data=lung, dist="gompertz")
plot(Gompertz)
I would like to create an output of KM survival curve and the extrapolation like in the plots.
For example with the KM curve (20 first time points):
v1 <- rep(NA,20)
v2<-1:20
for(i in 1:20){
v1[i] <- summary(kmsurvival, i)$surv
i=i+1
}
m1KM<-data.frame(v2,v1)
I would like to do the same with the Gompertz extrapolation, but I am not able to access the results applying this curve for each time point. Any help??? Thanks!
Upvotes: 1
Views: 1730
Reputation: 31452
You can access the predicted values of Gompertz in the est
column of its summary:
m1G <- summary(Gompertz)[[1]]
plot(est~time, data=m1G)
If you need to calculate the function at different time points than the original data, you can use
t <- 0:1000
summary(Gompertz, t=t)[[1]][,"est"]
Upvotes: 2