| scr_uplift | R Documentation |
Reads a score on a treated and a control group (a campaign with a hold-out): the difference of the event rates per score band with its interval, the incremental events, the Qini and uplift curves with their areas, and a check that the two groups have the same score distribution.
scr_uplift(x, ...)
## S3 method for class 'data.frame'
scr_uplift(
x,
score = "score",
y = "y",
treat = "treat",
n_bands = 10L,
cuts = NULL,
level = 0.95,
n_boot = 200L,
seed = NULL,
objective = "propensity",
direction = NULL,
weight = NULL,
max_cells = 1e+05,
boot_cells = 10000,
...
)
x |
A |
... |
Passed on to the methods; an unknown argument is an error. |
score, y, treat |
Column names of the score, of the 0/1 outcome ( |
n_bands |
Equal-share bands of the score when |
cuts |
Optional ascending cuts of the score, or an object from
|
level |
Confidence level of the intervals. |
n_boot |
Bootstrap resamples of the Qini and AUUC intervals ( |
seed |
Seed of the bootstrap. A number is local to the call (the
user's random stream is restored on exit); |
objective |
|
direction |
|
weight |
Optional column of non-negative case weights. |
max_cells |
Largest number of distinct score values kept exactly. |
boot_cells |
Largest number of score cells resampled exactly by the
bootstrap (default 10,000; |
An object of class c("scr_uplift", "list"):
tableOne row per band, event-richest first: band,
label, score_lo, score_hi, n_t, n_c, events_t,
events_c, rate_t, rate_c, uplift, uplift_lo, uplift_hi,
incremental, cum_incremental, cum_pct_treated and type.
summaryOne row: n_t, n_c, rate_t, rate_c, uplift,
uplift_lo, uplift_hi, qini, qini_lo, qini_hi, auuc,
auuc_lo, auuc_hi, psi, psi_critical and psi_flag.
curveThe curves, at most about 1,000 rows spread evenly in
the treated share (the areas use every cell): cut (the score
boundary), pct_treated, pct_all, n_t, n_c, qini,
qini_random (the straight line) and uplift.
randomizationA list: psi, critical, flag and note.
cuts, codes, labels, level, n_boot, objective,
direction, score, target, treat, weighted, callThe cuts and the settings.
The bands are cut on the score of both arms together, tie-safe as in
scr_bands(), the event-richest end first (band = 1). Per band, with
n_t, n_c the rows with a known outcome and r_t,
r_c the event rates of the treated and of the control:
uplift = r_t - r_c, with the Newcombe hybrid score
interval: from the Wilson intervals [l_t, u_t] and
[l_c, u_c] of the two rates,
lo = r_t - r_c - \sqrt{(r_t - l_t)^2 + (u_c - r_c)^2}, \qquad
hi = r_t - r_c + \sqrt{(u_t - r_t)^2 + (r_c - l_c)^2}.
Under weights the Wilson intervals use the Kish effective sizes.
incremental = uplift \times n_t: the events of the
treated that the treatment added; cum_incremental is its running
sum from the first band (a band with an empty arm adds nothing) and
cum_pct_treated the cumulative share of the treated.
type, a convention of this package: "persuadable" when the
interval lies above 0, "negative" when it lies below, "no effect"
when it covers 0.
The score cells are accumulated from the event-rich end. With
E_t(k), E_c(k) the cumulative events and N_t(k),
N_c(k) the cumulative rows of each arm after k cells:
the Qini curve is
Q(k) = E_t(k) - E_c(k) N_t(k) / N_c(k) (the second term is 0
while no control row is in), read against N_t(k);
qini is the area between the Qini curve and the straight line
from the origin to its end point, by trapezoids from the origin,
divided by the square of the treated volume:
qini = \frac{1}{N_t^2} \sum_k \frac{Q(k-1) + Q(k)}{2}
(N_t(k) - N_t(k-1)) - \frac{Q(K)}{2 N_t}.
It is 0 for a score that orders at random and positive when the incremental events come first;
the uplift curve is
U(k) = (E_t(k) / N_t(k) - E_c(k) / N_c(k)) (N_t(k) + N_c(k)) / N
(an arm with no row yet has rate 0), read against the cumulative
share of all rows (N_t(k) + N_c(k)) / N; auuc is the area
under it by trapezoids from the origin. A score that orders at random
gives about half the overall uplift.
Rows with a missing outcome are left out of the rates and of the curves.
qini is not Radcliffe's Q, which divides the same area by that of an
ideal curve; here the area is divided by N_t^2 only, so it reads
as incremental events per treated row, averaged over the depth.
The intervals of qini and auuc are percentile intervals of a
bootstrap on the counts, stratified by arm: each resample draws, for the
treated and for the control separately, the counts per score cell and
outcome from one multinomial law with the observed shares and the
unweighted size of the arm, the law of a row bootstrap within each arm.
The event totals of the arms vary from one resample to the next, so the
intervals carry the uncertainty of the overall uplift as well as that of
the ordering. Above boot_cells cells the resamples run on pooled cells
and are shifted to the point estimates, as in scr_bands(). A given
seed is local to the call.
Under a randomized assignment the score has the same distribution in
both arms. randomization holds the PSI of the treated against the
control over the bands, with the n-adjusted critical value at
1 - level (see scr_psi()); when the PSI exceeds it, flag is TRUE
and note says so: the arms then differ along the score and the uplift
may reflect the assignment, not the treatment.
Newcombe, R. G. (1998). Interval estimation for the difference between independent proportions: comparison of eleven methods. Statistics in Medicine, 17(8), 873-890.
Radcliffe, N. J. (2007). Using control groups to target on predicted lift: building and assessing uplift models. Direct Marketing Analytics Journal, 1, 14-21.
Yurdakul, B. and Naranjo, J. (2020). Statistical properties of the population stability index. Journal of Risk Model Validation, 14(4), 89-100.
scr_bands() for the bands, scr_operating() for the cut of a
campaign under a budget.
Other score-studies:
scr_bands(),
scr_claims(),
scr_detection(),
scr_maturity(),
scr_mix_shift(),
scr_operating(),
scr_overlap(),
scr_rag(),
scr_rag_plan(),
scr_score_cross(),
scr_segments(),
scr_tiers()
local({
set.seed(1)
n <- 8000
x <- rnorm(n)
treat <- rbinom(n, 1, 0.5)
# the offer works on the customers with a high score only
d <- data.frame(score = round(500 + 50 * x), treat = treat,
y = rbinom(n, 1, plogis(-1.5 + 0.5 * x + treat * pmax(x, 0))))
up <- scr_uplift(d, n_bands = 5, n_boot = 50, seed = 1)
print(up)
up$summary[, c("uplift", "qini", "qini_lo", "qini_hi", "auuc")]
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.