開始使用免費開始

使用 survreg() 估計存活曲線

現在你可以用 Weibull 模型來估計 GBSG2 資料中乳癌病患的存活。

Weibull 分佈有 2 個參數,用來決定存活曲線的形狀。

本練習已為你載入 survival 套件與 GBSG2 資料。

本練習屬於課程

R 的生存分析

檢視課程

練習說明

  • 為乳癌病患估計一個 Weibull 模型。
  • 使用 predict() 並設定 type = "quantile",從模型計算估計的存活曲線。
  • 建立一個含有時間點與對應存活機率的 data.frame
  • 使用 head() 檢視結果的前幾列。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Weibull model
wb <- ___(___(___, ___) ~ ___, data = ___)

# Retrieve survival curve from model probabilities 
surv <- seq(.99, .01, by = -.01)

# Get time for each probability
t <- predict(___, type = ___, p = ___, newdata = data.frame(1))

# Create data frame with the information
surv_wb <- data.frame(time = ___, surv = ___)

# Look at first few lines of the result
head(___)
編輯並執行程式碼