2016-11-30 48 views
0

我正在嘗試生成KM曲線,並希望像往常一樣在圖表中顯示審查事件(如交叉或等效)。在R版本中繪製審查事件3.3.2

我使用上面的R版本,並更新了包裝「生存」,「KMsurv」和「rms」。

我試圖在某些網站上顯示的代碼沒有成功。

實施例從http://www.visualcinnamon.com/2013/07/plotting-survival-analysis-results-in-r.html

library(survival) 
data(colon) 
fit = survfit(Surv(time,status)~rx, data=colon) 
plot(fit, xlab="Time", ylab="Survival Probability", main="Kaplan-Meier plot") 

我生成KM曲線,但刪事件不被圖形地表示。

我也嘗試(使用RMS包裝):

fit <- npsurv(Surv(time,status)~rx, data=colon) 
survplot(fit) 

毫無效果。我錯過了什麼?

PS:mark.time在基礎R工作,但我特別感興趣的是一個累積概率圖(AKA「倒轉KM」),我不認爲這可以在R基礎上輕鬆完成。 rms使用參數:'fun = function(x){1-x}'

+0

對不起,好像我搞砸了如何適當地發佈代碼,它都被加入到一行中。我很抱歉。 – Marcos

+0

您是否嘗試將參數'mark.time'設置爲'TRUE'?它應該有所幫助...(詳情請參閱'plot.survfit') – Cath

+0

感謝Cath,編輯我的文章和指出如何使用base R做到這一點。是否有一個等同的參數'survplot' RMS包中的函數? – Marcos

回答

0

我的猜測是這三個調用中的一個(或更多)調用(記錄在?points.survfit頁面中,該頁面又從?plot.survfit頁面):

plot(fit, xlab="Time", ylab="Haz Probability", main="Kaplan-Meier plot", 
      fun="cumhaz") # the cumulative Hazard is 1-Survival 
plot(fit, xlab="Time", ylab="Haz Probability", main="Kaplan-Meier plot", 
      fun="cumhaz", conf.int=TRUE) 
plot(fit, xlab="Time", ylab="Haz Probability", main="Kaplan-Meier plot", 
      fun="cumhaz", conf.int=TRUE, mark.time=TRUE) # censoring markers 

最後一個產生:

enter image description here

+0

謝謝先生。這很好。我也想讓人們知道包裹「倖存者」,它的功能「ggsurvplot」非常了不起。當然,我在這裏發佈我的問題後發現了這個問題。 http://www.sthda.com/english/rpkgs/survminer/ggsurvplot.html – Marcos