plot_uplift: Creates an uplift plot of cumulative differential...

Description Usage Arguments Examples

Description

Creates an uplift plot of cumulative differential treatment/control outcomes versus model score. Also provides a selection of metrics: max uplift as pct of total control outcome, optimum users targeted and optimum score targeting range.

Usage

1
2
3
plot_uplift(p1, W, Y, ns = min(table(W)), n_bs = 1, W_label = W,
  p0 = rep(0, length(p1)), balanced = TRUE, replace = TRUE,
  x_interval = 0.1, ...)

Arguments

p1

numeric vector of uplift predictions; can also be predicted outcomes for treated case (in this case p0 should contain predicted outcomes for the control case)

W

binary vector 1,0 of treatment assignments

Y

numeric vector of responses

ns

integer number of samples per bootstrap iteration; default min(table(W))

n_bs

integer number of bootstrap iterations

W_label

optional labels for the treatment options (default W)

p0

optional numeric vector of predicted outcomes for control case

balanced

optional boolean whether to sample equal proportions from treatment and control cases; default TRUE

replace

optional boolean whether to use replacement when sampling; default TRUE

x_interval

optional numeric the interval with which to split the

...

additional arguments (unused) x-axis

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
31
32
33
34
35
36
37
38
set.seed(0)
rl <- function(x){
  round(1/(1+exp(-x)))
}
n <- 2000; p <- 3
beta <- -0.5
X <- matrix(rnorm(n*p), n, p)
W <- rbinom(n, 1, 0.5)
Y <- rl(pmax(beta+X[,1], 0) * W + X[,2])
p1 <- 1/(1+exp(-(beta+X[,1])))
plot_uplift(p1, W, Y, n_bs=20, x_interval = 0.05, balanced = TRUE)


set.seed(0)
n <- 2000; p <- 3
beta <- -0.5
X <- matrix(rnorm(n*p), n, p)
W <- rbinom(n, 1, 0.5)
Y <- pmax(beta+X[,1], 0) * W + X[,2]
p1 <- 1/(1+exp(-(beta+X[,1])))
plot_uplift(p1, W, Y, n_bs=20, x_interval = 0.05, balanced = TRUE)



library(grf)
set.seed(123)

rl <- function(x){
  round(1/(1+exp(-x)))
}
n = 2000; p = 10
X = matrix(rnorm(n*p), n, p)
W = rbinom(n, 1, 0.2)
Y = rl(rl(X[,1]) * W - rl(X[,3]) * W + rnorm(n))
tau.forest = causal_forest(X, Y, W)
tau.hat = predict(tau.forest, X)
plot_uplift(tau.hat$predictions, W, Y, n_bs=20, x_interval = 0.05, balanced = FALSE)
plot_uplift(tau.hat$predictions, W, Y, n_bs=20, x_interval = 0.05, balanced = TRUE)

uplifteval documentation built on June 15, 2019, 9:03 a.m.