Description Usage Arguments Value Author(s) References Examples

View source: R/proj2_plotFun.R

Flexible function for plotting the calibration curve for a risk score and different recalibrations of a risk score. Histograms of risk score and recalibrated risk scores can be plotted using argument "hist==TRUE". Dotted guidelines for the risk threshold R are plotted and clinically releavant risk region [R_l, R_u] are plotted to help gauge calibration in clinically relevants.

1 2 3 4 5 6 7 8 9 10 | ```
calCurvPlot(y,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,rl = -Inf, ru = Inf)
``` |

`y` |
Vector of binary outcomes, with 1 indicating event (case) and 0 indicating no event (controls) |

`p` |
Vector of risk score values |

`p.std` |
Vector of risk score values after standard logistic recalibration |

`p.recal` |
Vector of risk score values after weighted/contratined logistic recalibration |

`stdPlot` |
If TRUE plot calibration curve for standard logistic recalibrated risk score |

`recalPlot` |
If TRUE plot calibration curve for weighted/contratined recalibrated risk score |

`xlim` |
Limits for x-axis |

`ylim` |
Limits for y-axis |

`label` |
Label for x-axis corresponding to p vector |

`label2` |
Label for x-axis corresponding to p.std vector |

`label3` |
Label for x-axis corresponding to p.recal vector |

`legendLab` |
Label for legend |

`mainTitle` |
Main title for plot |

`hist` |
If true plot distribution of risk scores along with calibration curve |

`ylimHist` |
Limits for y-axis of histogram |

`r` |
Clinically relevant risk threshold used indicated with dotted line |

`rl` |
Lower bound of clinically relevant region indicated with dotted-dashed line |

`ru` |
Upper bound of clinically relevant region indicated with dotted-dashed line |

Prints calibration plot of risk model p, and optional histogram of risk score

Anu Mishra

Mishra, A. (2019). Methods for Risk Markers that Incorporate Clinical Utility (Doctoral dissertation). (Available Upon Request)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ```
## 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)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.