I want to compute predicted survivor function for a Cox proportional hazards model with frailty terms [using survival package]. It appears that when frailty terms are in the model, the predicted survivor function cannot be computed.
## Example
require(survival)
data(rats)
## Create fake weight
set.seed(90989)
rats$weight<-runif(nrow(rats),0.2,0.9)
## Cox model with gamma frailty on litter
fit <- coxph(Surv(time, status) ~ rx+weight+frailty(litter,dist="gamma"),
data = rats)
## Compute survival curve from the cox model for rx=0 and weight=0.5 kg
plot(survfit(fit, newdata=data.frame(rx=0,weight=0.5)),xlab = "time",
ylab="Survival")
## Running this line, I get following error message:
Error in survfit.coxph(fit, newdata = data.frame(rx = 0, weight = 0.5)) :
Newdata cannot be used when a model has sparse frailty terms
I tried using both sparse and non-sparse computation methods by using
sparse=TRUE, Sparse =FALSE, sparse =0, sparse=5
options. However, none
worked.
How do I compute predicted survivor curve based on my frailty model?