ワイブル モデルを生存データに適合させてプロットしようとしています。データには、2006 年から 2010 年まで実行されるコホートという 1 つの共変量しかありません。では、2010 年のコホートの生存曲線をプロットするために続く 2 行のコードに何を追加すればよいでしょうか?
library(survival)
s <- Surv(subSetCdm$dur,subSetCdm$event)
sWei <- survreg(s ~ cohort,dist='weibull',data=subSetCdm)
Cox PH モデルで同じことを達成するのは、次の行でかなり簡単です。問題は、survfit() が survreg 型のオブジェクトを受け入れないことです。
sCox <- coxph(s ~ cohort,data=subSetCdm)
cohort <- factor(c(2010),levels=2006:2010)
sfCox <- survfit(sCox,newdata=data.frame(cohort))
plot(sfCox,col='green')
(生存パッケージからの)データ肺を使用して、これが私が達成しようとしていることです。
#create a Surv object
s <- with(lung,Surv(time,status))
#plot kaplan-meier estimate, per sex
fKM <- survfit(s ~ sex,data=lung)
plot(fKM)
#plot Cox PH survival curves, per sex
sCox <- coxph(s ~ as.factor(sex),data=lung)
lines(survfit(sCox,newdata=data.frame(sex=1)),col='green')
lines(survfit(sCox,newdata=data.frame(sex=2)),col='green')
#plot weibull survival curves, per sex, DOES NOT RUN
sWei <- survreg(s ~ as.factor(sex),dist='weibull',data=lung)
lines(survfit(sWei,newdata=data.frame(sex=1)),col='red')
lines(survfit(sWei,newdata=data.frame(sex=2)),col='red')