Learn R Programming

RBPcurve (version 1.2)

plotRBPCurve: Plot residual-based predictiveness (RBP) curve.

Description

plots the RBP curve

Usage

plotRBPCurve(obj, main = "RBP Curve", xlab = "Cumulative Percentage",
  ylab = "Estimated Residuals", type = "l", ylim = c(-1, 1.2),
  x.adj = c(NA, -0.5), y.adj = c(NA, NA), cond.axis = FALSE,
  title.line = ifelse(cond.axis, 3, 2), add = FALSE, ...)

Arguments

obj
[RBPObj] Data container for RBP curve.
main
[character(1)] An overall title for the plot.
xlab
[character(1)] Label for X-axis. Default is “Cumulative Percentage”.
ylab
[character(1)] Label for Y-axis. Default is “Estimated Residuals”.
type
[character(1)] The plot type that should be drawn, see plot for all possible types. Default is type = "l" for lines.
ylim
[numeric(2)] Limits for Y-axis. Default is c(-1, 1.1).
x.adj
[numeric(2)] Adjustment for the X-axis.
y.adj
[numeric(2)] Adjustment for the Y-axis.
cond.axis
[logical(1)] Should an additional axis be plotted reflecting residuals conditional on y? Default is FALSE.
title.line
[integer(1)] Where to plot the title, see title.
add
[logical(1)] Should RBP plot be added to current plot? Default is FALSE.
...
[any] Passed to plot or lines, depending on add.

Examples

Run this code

# Download data
mydata = getTaskData(pid.task)
head(mydata)

# Build logit model and plot RBP curve
mylogit <- glm(diabetes ~ ., data = mydata, family = "binomial")
y = mydata$diabetes
pred1 = predict(mylogit, type="response")
obj1 = makeRBPObj(pred1, y)
plotRBPCurve(obj1, cond.axis = TRUE, type = "b")

## Not run: ------------------------------------
# # Build logit model using mlr and plot RBP curve
# task = pid.task
# lrn = makeLearner("classif.logreg", predict.type = "prob")
# tr = train(lrn, task)
# pred2 = getPredictionProbabilities(predict(tr, task))
# obj2 = makeRBPObj(pred2, y)
# plotRBPCurve(obj2, cond.axis = TRUE, type = "b", col = 2)
## ---------------------------------------------

Run the code above in your browser using DataLab