gainstable.default | R Documentation |
Default S3 method to create gains table from a vector of diagnostic score and the class of observations.
## Default S3 method:
gainstable(score, class, negref = NULL, ngroup = 10, breaks = NULL, ... = NULL)
score |
An numeric array of diagnostic score. Same as in
|
class |
An array of equal length of score,
containing the class of the observations. Same as in |
negref |
The reference value, same as the
|
ngroup |
Number of desired groups in gains table. Ignored if
|
breaks |
Percentiles (in percentage) at which observations
should be separated to
form groups. If specified, |
... |
|
gainstable
function creates gains table containing
ngroup
number of groups or buckets. The algorithm first orders
the score variable with respect to score variable. In case of tie,
it class becomes the ordering variable, keeping the positive responses first.
The algorithm calculates the ending index in each bucket as
round((length(score) / ngroup) * (1:ngroup))
. Each bucket should have
at least 5 observations.
If buckets' end index are to be ended at desired level of
population, then breaks
should be specified.
If specified, it overrides ngroup
and ngroup
is ignored.
breaks
by default always includes 100. If whole number does not exist
at specified population, nearest integers are considered.
A list of class "gainstable"
. It has the following components:
Bucket |
The serial number of buckets or groups. |
Obs |
Number of observation in the group. |
CObs |
Cumulative number of observations up to the group. |
Depth |
Cumulative population depth up to the group. |
Resp |
Number of (positive) responses in the group. |
CResp |
Cumulative number of (positive) responses up to the group. |
RespRate |
(Positive) response rate in the group. |
CRespRate |
Cumulative (positive) response rate up to the group |
CCapRate |
Cumulative overall capture rate of (positive) responses up to the group. |
Lift |
Lift index in the group. Calculated as
|
CLift |
Cumulative lift index up to the group. |
The algorithm is designed for complete cases. If NA(s) found in
either score
or class
, then removed.
gainstable.rocit
, plot.gainstable
,
rocit
data("Loan")
class <- Loan$Status
score <- Loan$Score
# ----------------------------------------------------------------
gtable15 <- gainstable(score = score, class = class,
negref = "FP", ngroup = 15)
gtable_custom <- gainstable(score = score, class = class,
negref = "FP", breaks = seq(1,100,15))
# ----------------------------------------------------------------
print(gtable15)
print(gtable_custom)
# ----------------------------------------------------------------
plot(gtable15)
plot(gtable_custom)
plot(gtable_custom, type = 2)
plot(gtable_custom, type = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.