Description Usage Arguments Examples
A direct copy of Leo Guelman's uplift::qini function available in the R uplift package at commit 95965272e71c312623c95c439fb0b84f95c185b7: https://github.com/cran/uplift/blob/95965272e71c312623c95c439fb0b84f95c185b7/R/qini.R#L5
1 2 | plot_uplift_guelman(p1, W, Y, p0 = rep(0, length(p1)), plotit = TRUE,
direction = 1, groups = 10)
|
p1 |
vector of numeric uplift predictions. Some uplift models produce two predictions: if-treated and if-control. In this case, if-treated predictions can be provided as p1, and if-control predictions can be provided as p0. |
W |
vector of 0,1 treatment indicators |
Y |
vector of 0,1 outcomes |
p0 |
vector of numeric control predictions (default 0) |
plotit |
boolean plot the Qini chart |
direction |
1: calculate the differential response as p1-p0, 2: p0-p1 |
groups |
5, 10, or 20: the number of quantiles in which to divide the population |
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 | 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_guelman(p1, W, Y, groups=10, plotit=TRUE)
library(grf)
set.seed(123)
alpha <- 0.1
n <- 1000
W <- rbinom(n, 1, 0.5)
Y <- W
p1 <- Y + alpha*rnorm(n)
plot_uplift_guelman(p1, W, Y, groups=10)
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_guelman(tau.hat$predictions, W, Y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.