data(readmission)
##-- predictions on a Cox proportionnal hazard model --##
cox <- frailtyPenal(Surv(time,event)~sex+dukes,
n.knots=10,kappa1=10000,data=readmission,Frailty=FALSE)
#-- construction of the dataframe for predictions
datapred <- data.frame(sex=0,dukes=0)
datapred$sex <- as.factor(datapred$sex)
levels(datapred$sex)<- c(1,2)
datapred$dukes <- as.factor(datapred$dukes)
levels(datapred$dukes)<- c(1,2,3)
datapred[1,] <- c(1,2)
datapred[2,] <- c(2,3)
#-- prediction of the event for two patients, between time 100 and time 2000
pred.cox <- prediction(cox,datapred,100,50,2000)
plot(pred.cox)
##-- predictions on a shared frailty model --##
sha <- frailtyPenal(Surv(time,event)~cluster(id)+sex+dukes,
n.knots=10,kappa1=10000,data=readmission,Frailty=TRUE)
#-- marginal prediction
pred.sha.marg <- prediction(sha,datapred,100,50,2000,type="marginal")
plot(pred.sha.marg)
#-- conditional prediction, given a specific cluster (group=5)
pred.sha.cond <- prediction(sha,datapred,100,50,2000,type="conditional",group=5)
plot(pred.sha.cond)
##-- predictions on a joint frailty model --##
joi <- frailtyPenal(Surv(t.start,t.stop,event)~cluster(id)
+sex+dukes+terminal(death),formula.terminalEvent=~sex
+dukes,data=readmission,n.knots=10,kappa1=9.55e9,
kappa2=1.41e12,Frailty=TRUE,joint=TRUE,recurrentAG=TRUE)
#-- creation of the dataframe for predictions
datapredj <- data.frame(t.stop=0,id=0,sex=0,dukes=0)
datapredj$sex <- as.factor(datapredj$sex)
levels(datapredj$sex) <- c(1,2)
datapredj$dukes <- as.factor(datapredj$dukes)
levels(datapredj$dukes) <- c(1,2,3)
datapredj[1,] <- c(100,1,1,2)
datapredj[2,] <- c(200,1,1,2)
datapredj[3,] <- c(300,1,1,2)
datapredj[4,] <- c(400,1,1,2)
datapredj[5,] <- c(380,2,1,2)
#-- only recurrences observed before the prediction
#-- time should be included in the 'datapred'
pred.joint <- prediction(joi,datapredj,500,50,2000)
plot(pred.joint)Run the code above in your browser using DataLab