Estimating median survival from a Weibull model
We can now estimate the survival of the breast cancer patients in the GBSG2
data using a Weibull model (function survreg()
).
Remember, the Weibull model estimates a smooth survival function instead of a step function, which is what the Kaplan-Meier method estimates.
The predict()
function with type = "quantile"
allows us to compute the quantiles of the distribution
function. We will use this to compute the median survival.
The survival
package and the GBSG2
data are loaded for you in this exercise.
This is a part of the course
“Survival Analysis in R”
Exercise instructions
- Estimate a Weibull model for the breast cancer patients.
- Compute the median survival from this model using the
predict()
function withtype = "quantile"
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Weibull model
wb <- ___(Surv(time, cens) ~ 1, data = GBSG2)
# Compute the median survival from the model
predict(wb, type = "quantile", p = ___, newdata = data.frame(1))
This exercise is part of the course
Survival Analysis in R
Learn to work with time-to-event data. The event may be death or finding a job after unemployment. Learn to estimate, visualize, and interpret survival models!
In this chapter, we will look into different methods of estimating survival curves. We will discuss the Kaplan-Meier estimate and the Weibull model as tools for survival curve estimation and learn how to communicate those results through visualization.
Exercise 1: Kaplan-Meier estimateExercise 2: Function to compute the Kaplan-Meier estimateExercise 3: First Kaplan-Meier estimateExercise 4: When does the Kaplan-Meier curve drop?Exercise 5: Why use Kaplan-MeierExercise 6: Understanding and visualizing Kaplan-Meier curvesExercise 7: Exercise ignoring censoringExercise 8: Estimating and visualizing a survival curveExercise 9: The Weibull model for estimating survival curvesExercise 10: Estimating median survival from a Weibull modelExercise 11: Survival curve quantiles from a Weibull modelExercise 12: Estimating the survival curve with survreg()Exercise 13: Visualizing the results of Weibull modelsExercise 14: Comparing Weibull model and Kaplan-Meier estimateWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.