Reputation: 637
This question follows on from the question here in that we want to plot a multi-variate model.
Lets say we want to plot the Survival function from the example in survreg
from the package release notes
Where the model is
survreg(Surv(time, status) ~ ph.ecog + age + strata(sex), lung)
From what I understand the following problem seems to address the problem, but does not provide a data set and only uses one variable. Where in this example, we have two continuous variables and one factor
Upvotes: 5
Views: 1299
Reputation: 263342
Plot for the predicted survival curve for hypothetical individual with mean of lung$age and the mode of lung$ph.ecog (following the example in the help page):
?predict.survreg
pct <- 1:98/100
ptime <- predict(res, newdata=data.frame(ph.ecog=1, age=62.44737, sex=1), type='quantile',
p=pct, se=TRUE)
matplot(cbind(ptime$fit, ptime$fit + 2*ptime$se.fit,
ptime$fit - 2*ptime$se.fit)/30.5, 1-pct,
xlab="Months", ylab="Survival", type='l', lty=c(1,2,2), col=1)
Upvotes: 4