我想从时间到事件riskRegression::FGR()竞争风险模型对象中提取观察到的和预测的估计值。
下面是一些模拟数据:
library(simstudy)
library(data.table)
library(survival)
library(riskRegression)
library(cmprsk)
library(prodlim)
#Generate time to event data
d1 <- defData(varname = "x1", formula = .5, dist = "binary")
d1 <- defData(d1, "x2", .5, dist = "binary")
head(dtSurv)
f <- "(time==censor)*0 + (time==event_1)*1 + (time==event_2)*2 + (time==event_3)*3"
cdef <- defDataAdd(varname = "time",
formula = "pmin(censor, event_1, event_2, event_3)", dist = "nonrandom")
cdef <- defDataAdd(varname = "time",
formula = "pmin(censor, event_1, event_2, event_3)", dist = "nonrandom")
cdef <- defDataAdd(cdef, varname = "event",
formula = f,
dist = "nonrandom")
dtSurv_final <- addCompRisk(dtSurv,
events = c("event_1", "event_2", "event_3", "censor"),
timeName = "time", censorName = "censor")
head(dtSurv_final)
#Fit subdistribution model
crr<-riskRegression::FGR(Hist(time, event)~ x1+x2 ,data=dtSurv_final, cause=1)
crr.object<-riskRegression::Score(list(model1=crr),
Hist(time,event)~1,data=dtSurv_final, cause=1, times=30, plots="cal")
#Store model output
(cal<-crr.object[["Calibration"]]$plotframe %>% as.data.frame())
我尝试从cal
中提取观察到的和预测的风险,但无法做到这一点。
1条答案
按热度按时间hgqdbh6s1#
对于“观察到的”累积发生率,您可以简单地使用
cmprsk
包的cuminc
函数。现在,这取决于你所说的“预测累积发病率”是什么意思。如果您只是在给定一组协变量和FGR模型的情况下查找t时的特定原因失效概率,则可以直接使用
riskRegression
包中出色的predictRisk
函数。如果您想绘制特定原因的故障概率的边际估计值,则可以使用
adjustedCurves
包的adjustedcif
函数。