plotRiskDistribution {PredictABEL} | R Documentation |
Function to plot histogram of risks separated for individuals with and without the outcome of interest.
Description
Function to plot histogram of risks separated for individuals with and without the outcome of interest.
Usage
plotRiskDistribution(data, cOutcome, risks, interval, rangexaxis,
rangeyaxis, plottitle, xlabel, ylabel, labels, fileplot, plottype)
Arguments
data |
Data frame or numeric matrix that includes the outcome and predictor variables. |
cOutcome |
Column number of the outcome variable. |
risks |
Risk of each individual. It is specified by either a vector of risk scores or a vector of predicted risks. |
interval |
Size of the risk intervals. For example, |
rangexaxis |
Range of the x-axis. Specification of |
rangeyaxis |
Range of the y-axis. |
plottitle |
Title of the plot. Specification of |
xlabel |
Label of x-axis. Specification of |
ylabel |
Label of y-axis. Specification of |
labels |
Labels given to the groups of individuals without and
with the outcome of interest. Specification of |
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, |
Value
The function creates the histogram of risks separated for individuals with and without the outcome of interest.
See Also
Examples
# specify dataset with outcome and predictor variables
data(ExampleData)
# specify column number of the outcome variable
cOutcome <- 2
# fit a logistic regression model
# all steps needed to construct a logistic regression model are written in a function
# called 'ExampleModels', which is described on page 4-5
riskmodel <- ExampleModels()$riskModel2
# obtain predicted risks
predRisk <- predRisk(riskmodel)
# specify the size of each interval
interval <- .05
# specify label of x-axis
xlabel <- "Predicted risk"
# specify label of y-axis
ylabel <- "Percentage"
# specify range of x-axis
xrange <- c(0,1)
# specify range of y-axis
yrange <- c(0,40)
# specify title for the plot
maintitle <- "Distribution of predicted risks"
# specify labels
labels <- c("Without outcome", "With outcome")
# produce risk distribution plot
plotRiskDistribution(data=ExampleData, cOutcome=cOutcome,
risks=predRisk, interval=interval, plottitle=maintitle, rangexaxis=xrange,
rangeyaxis=yrange, xlabel=xlabel, ylabel=ylabel, labels=labels)