plotPriorPosteriorRisk: Function to plot posterior risks against prior risks.

Description Usage Arguments Details Value See Also Examples

Description

Function to plot posterior risks against prior risks.

Usage

1
2
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 plottitle is optional. Default is "PriorPosteriorRisk plot".

xlabel

Label of x-axis. Specification of xlabel is optional. Default is "Prior risk".

ylabel

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

rangeaxis

Range of x-axis and y-axis. Specification of rangeaxis is optional. Default is c(0,1).

plotAll

plotAll=TRUE will create one plot for the total population. When plotAll=FALSE separate plots will be created for individuals with and without the outcome of interest. means two separate plots for with and without outcome of interest.

labels

Labels given to the groups of individuals without and with the outcome of interest. Default labels is c("without outcome", "with outcome"). Note that when plotAll=TRUE, specification of labels is not necessary.

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 filename is specified, the output is not saved.

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.

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

predRisk

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
# 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)

PredictABEL documentation built on March 13, 2020, 3:15 a.m.