gainsChartBarGraph: Produce a quantile bar graph based on gains chart(s)

Description Usage Arguments Value See Also Examples

View source: R/gainsChartBarGraph.R

Description

gainsChartBarGraph produces a bar graph based on a mt_gainsChart object. When two such objects are supplied, the function produces a combined bar graph, where the first object (xb) is labeled as "Build" and the second object (xv) is labeled as "Validate".

Usage

1
2
3
4
gainsChartBarGraph(xb, xv = NULL, cb = "#009DDC", cv = "#77BF30",
  xLabel = "Model Quantile", yLabel = "Mean Outcome",
  yType = ifelse("binary" %in% class(xb), "pct", "dlr"),
  yDigits = ifelse("binary" %in% class(xb), 1, 0))

Arguments

xb

mt_gainsChart object

xv

mt_gainsChart object

cb

character string; fill color for xb bars (valid color)

cv

character string; fill color for xv bars (valid color)

xLabel

character string; x-axis label

yLabel

character string; y-axis label

yType

character string; y-axis format type; valid values are "int", "dlr" and "pct"

yDigits

non-negative integer value indicating the number of decimal places to show when hovering over the bars

Value

A plot_ly visualization of a mt_gainsChart object, showing the average Y value (avgY for "binary"/"continuous"; perFreqYC for "combined") by quantile ( yhatBin).

See Also

gainsChart, plot_ly

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# pull in sample scored data frame
x <- modelSampleScored
# filter to validation subset
x <- split(x, x$ValidateFlag)
# gains chart binary
y <- lapply(x, function(z){gainsChart(z$TargetFlag, z$pTargetFlag)})
# bar graph
gainsChartBarGraph(y[[1]], y[[2]])
# gains chart continuous
y <- lapply(x, function(z){
    gainsChart(z[z$TargetFlag, "TargetValue"], z[z$TargetFlag, "pTargetValue"])
})
# bar graph
gainsChartBarGraph(y[[1]], y[[2]])
# gains chart combined
y <- lapply(x, function(z){
    gainsChart(z$TargetFlag, z$pTargetFlag*z$pTargetValue, z$TargetValue)
})
# bar graph
gainsChartBarGraph(y[[1]], y[[2]])

dnegrey/miscTools documentation built on May 3, 2019, 2:57 p.m.