# NOT RUN {
data("fakeData")
### get standard recalibrated risk score
stdRecal.res <- stdRecal(y = fakeData$y,p = fakeData$p)
p.std <- stdRecal.res$p.std
### Select tuning parameter lamba using 5-fold cross-validation repeated 25 times
grid <- RAWgrid(r = 0.3,rl = -Inf,ru = Inf,p = fakeData$p,y = fakeData$y,
cvParm = "lambda",rl.raw = 0.25,ru.raw = 0.35)
repCV <- cvRepWtTuning(y = fakeData$y,p = fakeData$p,rl = -Inf,ru = Inf,r = 0.3,
kFold = 5,cvRep = 25,cvParm = "lambda",tuneSeq = grid,stdErrRule = TRUE)
## Implement weighted logistic recalibration
wtRecal.res <- wtRecal(y = fakeData$y,p = fakeData$p,r = 0.3,rl = -Inf,ru = Inf,
lambda = repCV$cv.lambda,delta=1)
p.recal <- wtRecal.res$p.wt
### Calibration curve of only original risk score with histogram
calCurvPlot(y=fakeData$y,p=fakeData$p,p.std=NULL,p.recal=NULL,
stdPlot=FALSE, recalPlot=FALSE,
xlim=c(0,1),ylim=c(0,1),
label="Original Risk Score",
label2 = "Standard Recalibrated Risk Score",
label3 = "Weighted/Constrained Recalibrated Risk Score",
legendLab = c("Orig.", "Std.", "Wt."),
mainTitle="Calibration of Risk Score",
hist=TRUE,ylimHist = c(0,0.5),
r=0.3,rl = -Inf, ru = Inf)
### Calibration curve of only original, standard and weighted recalibrated risk score
calCurvPlot(fakeData$y,p=fakeData$p,p.std=p.std,p.recal=p.recal,
stdPlot=TRUE, recalPlot=TRUE,
xlim=c(0,1),ylim=c(0,1),
label="Original Risk Score",
label2 = "Standard Recalibrated Risk Score",
label3 = "Weighted/Constrained Recalibrated Risk Score",
legendLab = c("Orig.", "Std.", "Wt."),
mainTitle="Calibration of Risk Score",
hist=TRUE,ylimHist = c(0,0.5),
r=0.3,rl = -Inf, ru = Inf)
# }
Run the code above in your browser using DataLab