Load the library

library(survIDINRI)

read the sample data (PBC data in survival package)

D=subset(pbc, select=c("time","status","age","albumin","edema","protime","bili"))
D$status=as.numeric(D$status==2)
D=D[!is.na(apply(D,1,mean)),] ; dim(D)
## [1] 416   7

Lisiting a part of the data (outcome and predictors)

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 data, and sets of predictors for model 0 and model 1

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

Inference –> IDI.INF() function

t0=365*5
x<-IDI.INF(outcome, covs0, covs1, t0, npert=200) ;

Output –> IDI.INF.OUT() function

IDI.INF.OUT(x) ;
##     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 indicates IDI

M2 indicates NRI

M3 indicates Median difference

Graphical presentation

IDI.INF.GRAPH(x) ;