plotRiskDistribution: Function to plot histogram of risks separated for individuals...

Description Usage Arguments Value See Also Examples

Description

Function to plot histogram of risks separated for individuals with and without the outcome of interest.

Usage

1
2
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, interval=.1 will construct the following intervals for predicted risks: 0-0.1, 0.1-0.2,..., 0.9-1.

rangexaxis

Range of the x-axis. Specification of rangexaxis is optional.

rangeyaxis

Range of the y-axis.

plottitle

Title of the plot. Specification of plottitle is optional. Default is "Histogram of risks".

xlabel

Label of x-axis. Specification of xlabel is optional. Default is "Risk score".

ylabel

Label of y-axis. Specification of ylabel is optional. Default is "Percentage".

labels

Labels given to the groups of individuals without and with the outcome of interest. Specification of labels is optional. Default is c("Without outcome", "With outcome").

fileplot

Name of the output file that contains the plot. The file is saved in the working directory in the format specified under plottype. Example: fileplot="plotname". Note that the extension is not specified here. When fileplot is not specified, the plot is not saved.

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, plottype="eps" will save the plot in eps format. When plottype is not specified, the plot will be saved in jpg format.

Value

The function creates the histogram of risks separated for individuals with and without the outcome of interest.

See Also

plotROC, riskScore

Examples

 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)

PredictABEL documentation built on May 2, 2019, 5:01 p.m.