plotPriorPosteriorRisk {PredictABEL} | R Documentation |
Function to plot posterior risks against prior risks.
Description
Function to plot posterior risks against prior risks.
Usage
plotPriorPosteriorRisk(data, priorrisk, posteriorrisk, cOutcome, plottitle,
xlabel, ylabel, rangeaxis, plotAll=TRUE, labels, filename, fileplot, plottype)
Arguments
data |
Data frame or matrix that includes the outcome and predictors variables. |
priorrisk |
Vector of predicted risks based on initial model. |
posteriorrisk |
Vector of predicted risks based on updated model. |
cOutcome |
Column number of the outcome variable. |
plottitle |
Title of the plot. Specification of |
xlabel |
Label of x-axis. Specification of |
ylabel |
Label of y-axis. Specification of |
rangeaxis |
Range of x-axis and y-axis. Specification of |
plotAll |
|
labels |
Labels given to the groups of individuals without and with
the outcome of interest. Default |
filename |
Name of the output file in which prior and posterior
risks for each individual with the outcome will be saved. If no directory is
specified, the file is saved in the working directory as a txt file.
When no |
fileplot |
Name of the output file that contains the plot. The file is
saved in the working directory in the format specified under |
plottype |
The format in which the plot is saved. Available formats are
wmf, emf, png, jpg, jpeg, bmp, tif, tiff, ps,
eps or pdf. For example, |
Details
The function creates a plot of posterior risks (predicted risks using
the updated model) against prior risks (predicted risks using the initial
model). Predicted risks can be obtained using the functions
fitLogRegModel
and predRisk
or be
imported from other packages or methods.
Value
The function creates a plot of posterior risks against prior risks.
See Also
Examples
# specify dataset with outcome and predictor variables
data(ExampleData)
# specify column number of outcome variable
cOutcome <- 2
# fit logistic regression models
# all steps needed to construct a logistic regression model are written in a function
# called 'ExampleModels', which is described on page 4-5
riskmodel1 <- ExampleModels()$riskModel1
riskmodel2 <- ExampleModels()$riskModel2
# obtain predicted risks
predRisk1 <- predRisk(riskmodel1)
predRisk2 <- predRisk(riskmodel2)
# specify label of x-axis
xlabel <- "Prior risk"
# specify label of y-axis
ylabel <- "Posterior risk"
# specify title for the plot
titleplot <- "Prior versus posterior risk"
# specify range of the x-axis and y-axis
rangeaxis <- c(0,1)
# labels given to the groups without and with the outcome of interest
labels<- c("without outcome", "with outcome")
# produce prior risks and posterior risks plot
plotPriorPosteriorRisk(data=ExampleData, priorrisk=predRisk1,
posteriorrisk=predRisk2, cOutcome=cOutcome, xlabel=xlabel, ylabel=ylabel,
rangeaxis=rangeaxis, plotAll=TRUE, plottitle=titleplot, labels=labels)