D=D\[!is.na(apply(D,1,mean)),\] ; dim(D)
## \[1\] 416 7
head(D)
## time status age albumin edema protime bili
## 1 400 1 58.76523 2.60 1.0 12.2 14.5
## 2 4500 0 56.44627 4.14 0.0 10.6 1.1
## 3 1012 1 70.07255 3.48 0.5 12.0 1.4
## 4 1925 1 54.74059 2.54 0.5 10.3 1.8
## 5 1504 0 38.10541 3.53 0.0 10.9 3.4
## 6 2503 1 66.25873 3.98 0.0 11.0 0.8
outcome=D\[,c(1,2)\]
covs1<-as.matrix(D\[,c(-1,-2)\])
covs0<-as.matrix(D\[,c(-1,-2, -7)\])
head(outcome)
## time status
## 1 400 1
## 2 4500 0
## 3 1012 1
## 4 1925 1
## 5 1504 0
## 6 2503 1
``````
head(covs0)
## age albumin edema protime
## 1 58.76523 2.60 1.0 12.2
## 2 56.44627 4.14 0.0 10.6
## 3 70.07255 3.48 0.5 12.0
## 4 54.74059 2.54 0.5 10.3
## 5 38.10541 3.53 0.0 10.9
## 6 66.25873 3.98 0.0 11.0
``````
head(covs1)
## age albumin edema protime bili
## 1 58.76523 2.60 1.0 12.2 14.5
## 2 56.44627 4.14 0.0 10.6 1.1
## 3 70.07255 3.48 0.5 12.0 1.4
## 4 54.74059 2.54 0.5 10.3 1.8
## 5 38.10541 3.53 0.0 10.9 3.4
## 6 66.25873 3.98 0.0 11.0 0.8
<span style="color:#333333"><span style="color:#333333"><code><span style="color:#000000">t0</span><span style="color:#687687">=</span><span style="color:#009999">365</span><span style="color:#687687">*</span><span style="color:#009999">5</span>
<span style="color:#000000">x</span><span style="color:#687687"><-</span><span style="color:#000000">IDI </span><span style="color:#687687">(</span><span style="color:#000000">outcome</span>, <span style="color:#000000">covs0</span>, <span style="color:#000000">covs1</span>, <span style="color:#000000">t0</span>, <span style="color:#000000">npert</span><span style="color:#687687">=</span><span style="color:#009999">200</span><span style="color:#687687">)</span> ;</code></span></span>
## Est. Lower Upper p-value
## M1 0.090 0.052 0.119 0
## M2 0.457 0.340 0.566 0
## M3 0.041 0.025 0.062 0
M1表示IDI
M2表示NRI
M3表示中位数差异
本文摘选《R语言如何在生存分析与Cox回归中计算IDI,NRI指标》