Description Usage Arguments Value See Also Examples
Function to plot histogram of risks separated for individuals with and without the outcome of interest.
1 2 | plotRiskDistribution(data, cOutcome, risks, interval, rangexaxis,
rangeyaxis, plottitle, xlabel, ylabel, labels, fileplot, plottype)
|
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, |
The function creates the histogram of risks separated for individuals with and without the outcome of interest.
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 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.