比較 Weibull 與 Log-Normal 模型(一)
在這個練習中,你要把正確的存活機率加入到一個資料框。這個資料框將用來繪製存活曲線。surv_wide 是一個寬格式的資料框,包含荷爾蒙治療資訊,以及針對 Weibull 與 log-normal 模型的存活曲線。
本練習已為你載入 survival、survminer、reshape2 套件與 GBSG2 資料。
本練習屬於課程
R 的生存分析
練習說明
- 將資料框轉為長格式(long format)。
- 使用
surv_long$surv_id,把正確的存活機率surv加入資料框。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Melt the data.frame into long format.
surv_long <- melt(surv_wide, ___ = c("horTh", "dist"), ___ = "surv_id", ___ = "time")
# Add column for the survival probabilities
surv_long$surv <- surv[as.numeric(surv_long$___)]
# Add columns upper, lower, std.err, and strata contianing NA values
surv_long[, c("upper", "lower", "std.err", "strata")] <- NA