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
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With