library(survival)
library(reshape2)
library(ggplot2)
##Import the internal data of the R package
bc<-Breastcancer
##Categorical variables converted to factors
bc$histgrad<-as.factor(bc$histgrad)
bc$er<-as.factor(bc$er)
bc$pr<-as.factor(bc$pr)
bc$ln_yesno<-as.factor(bc$ln_yesno)
##Generate Survival Analysis Model
f1<-coxph(Surv(time,status)~er+histgrad+pr+age+ln_yesno,bc)
##Draw decision curve
scidca(f1)
scidca(f1,threshold.line = TRUE,threshold.text = TRUE)
##logistic regression model
fit<-glm(status~er+histgrad+pr+age+ln_yesno,family = binomial(link = "logit"),data=bc)
##Draw decision curve
scidca(f1)
scidca(f1,threshold.line = TRUE,threshold.text = TRUE)
##random forest model
library(randomForest)
LIRI<-LIRI
set.seed(1)
index <- sample(2,nrow(LIRI),replace = TRUE,prob=c(0.7,0.3))
traindata <- LIRI[index==1,]
testdata <- LIRI[index==2,]
traindata$status<-as.factor(traindata$status)
#Modelling random forests
fit<-randomForest(status ~ANLN+CENPA+GPR182+BCO2 ,data=traindata,ntree=500,
important=TRUE,proximity=TRUE)
scidca(fit,newdata = traindata)
scidca(fit,newdata = testdata )
scidca(fit,newdata = testdata ,threshold.line = TRUE,threshold.text = TRUE)
Run the code above in your browser using DataLab