Title: | A Bootstrap Proportion Test for Brand Lift Testing |
---|---|
Description: | A bootstrap proportion test for Brand Lift Testing to quantify the effectiveness of online advertising. Methods of the bootstrap proportion test are presented in Liu, Yu, Mao, Wu, Dyer (2023) <doi:10.1145/3583780.3615021>. |
Authors: | Wanjun Liu [aut, cre] |
Maintainer: | Wanjun Liu <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.0 |
Built: | 2024-12-06 06:28:53 UTC |
Source: | CRAN |
This function generates binomial random samples for the control group
(with sample size and success probability
) and the treatment
group (with sample size
and success probability
).
gen.simu.data(n1, n2, p1, p2, summary=TRUE)
gen.simu.data(n1, n2, p1, p2, summary=TRUE)
n1 |
sample size of the control group |
n2 |
sample size of the treatment group |
p1 |
success probability of the control group |
p2 |
success probability of the treatment group |
summary |
boolean variable. if TRUE it returns 2x2 contingency table; if FALSE it returns raw binomial random samples. By default, summary=TRUE. |
The a 2x2 contingency table is of the following form
col1 | col 2 |
control sample size | control positive response count |
treatment sample size | treatment positive response count |
A list of simulated data for the control group and the treatment group if summary=FALSE or a 2x2 contingency table if summary=TRUE
n1 <- 100; n2 <- 100; p1 <- 0.1; p2 <- 0.2 set.seed(1) sim.data <- gen.simu.data(n1, n2, p1, p2) sim.data
n1 <- 100; n2 <- 100; p1 <- 0.1; p2 <- 0.2 set.seed(1) sim.data <- gen.simu.data(n1, n2, p1, p2) sim.data
This function generates the asymptotic power of the proposed bootstrap test. Two methods are provided: the asymptotic power based on the relative lift and the asymptotic power the absolute lift. For more details, please refer to the paper Liu et al., (2023).
get.asymp.power(n1, n2, p1, p2, method='relative', alpha=0.05)
get.asymp.power(n1, n2, p1, p2, method='relative', alpha=0.05)
n1 |
sample size of the control group |
n2 |
sample size of the treatment group |
p1 |
success probability of the control group |
p2 |
success probability of the treatment group |
method |
two methods are provided: method =
c( |
alpha |
significance level. By default alpha = 0.05. |
Let and
. We define
where .
is the standard deviation of the absolute lift and
can be viewed as the standard deviation of
the combined sample of the control and treatment groups.
Let
be the absolute lift.
The asymptotic power function based on the absolute lift is given by
The asymptotic power function based on the relative lift is given by
where is the CDF of the standard normal distribution
,
is the upper
quantile of
,
and
.
Return the asymptotic power
Wanjun Liu, Xiufan Yu, Jialiang Mao, Xiaoxu Wu, and Justin Dyer. 2023. Quantifying the Effectiveness of Advertising: A Bootstrap Proportion Test for Brand Lift Testing. In Proceedings of the 32nd ACM International Conference on Information and Knowledge Management (CIKM ’23)
n1 <- 100; n2 <- 100; p1 <- 0.1; p2 <- 0.2 get.asymp.power(n1, n2, p1, p2, method='relative')
n1 <- 100; n2 <- 100; p1 <- 0.1; p2 <- 0.2 get.asymp.power(n1, n2, p1, p2, method='relative')
This function generates the minimum sample size required to obtain a statistically significant result for a given power. For more details, please refer to the paper Liu et al., (2023).
get.min.size(p1, p2, p_treat, method='relative', power=0.8, alpha=0.05)
get.min.size(p1, p2, p_treat, method='relative', power=0.8, alpha=0.05)
p1 |
success probability of the control group |
p2 |
success probability of the treatment group |
p_treat |
the percentage of the treatment group |
method |
two methods are provided: method =
c( |
power |
the power you want to achieve. Industry standard is power = 0.8, which is also the default value |
alpha |
significance level. By default alpha = 0.05 |
The minimum required sample size is approximated by the asymptotic
power function.
Let and
. We define
where .
is the standard deviation of the absolute lift and
can be viewed as the standard deviation of
the combined sample of the control and treatment groups.
Let
be the absolute lift.
The asymptotic power function based on the absolute lift is given by
The asymptotic power function based on the relative lift is given by
where is the CDF of the standard normal distribution
,
is the upper
quantile of
,
and
.
Given a power (say power=0.80), it is difficult to get a closed form of the
minimum sample size. Note that when , the first term of
the power function dominates the second term, so we can ignore the second
term and derive the closed form for the minimum sample size. Similarly,
when
, the second term of the power function dominates
the first term, so we can ignore the first term. In particular, the closed
form for the minimum sample size is given by
Return the required minimum sample size. This is the total sample size of control group + treatment group
Wanjun Liu, Xiufan Yu, Jialiang Mao, Xiaoxu Wu, and Justin Dyer. 2023. Quantifying the Effectiveness of Advertising: A Bootstrap Proportion Test for Brand Lift Testing. In Proceedings of the 32nd ACM International Conference on Information and Knowledge Management (CIKM ’23)
p1 <- 0.1; p2 <- 0.2 get.min.size(p1, p2, p_treat=0.5, method='relative', power=0.8, alpha=0.05)
p1 <- 0.1; p2 <- 0.2 get.min.size(p1, p2, p_treat=0.5, method='relative', power=0.8, alpha=0.05)
This function implements several proportion tests that can be applied to Brand Lift Testing, including
: Absolute lift based Z-test and relative lift based Z-test. The limiting
distribution of Z-statistics are derived from the central limit theorem.
: Absolute lift based bootstrap test (BS-A) and relative lift based
bootstrap test (BS-R), see Liu et al., (2023).
: Absolute lift based bootstrap mean test and relative lift
based bootstrap mean test. (Efron and Tibshirani 1994).
: Absolute lift based permutation test and relative lift based
permutation test. (Efron and Tibshirani 1994).
Learn more about the proportion tests in the section Details.
proportion.test(data, method, B)
proportion.test(data, method, B)
data |
A 2x2 matrix with first column being (control sample size, treatment sample size) and the 2nd column being (control positive response count, treatment positive response count). |
method |
The method should be one of ("clt", "bootstrap", "bootstrapmean", "permutation") |
B |
Number of replications for bootstrap test or permutation test. Only required for methods "bootstrap", "bootstrapmean", "permutation". |
: the classic Z-test based on normal approximation. The absolute
lift based Z-test is defined as
and he relative lift based Z-test is defined as
where and
.
: the bootstrap proportion tests proposed in Liu et al., (2023),
see Algorithm 1 in their paper. There are two bootstrap tests: the absolute lift
based bootstrap test BS-A and the relative lift based bootstrap test BS-R. Note that
this type of bootstrap test is testing whether the distribution of the control group is
the same as the distribution of the treatment group. In the binomial distribution case,
it is equivalent to test whether the mean of the control group is
the same as the mean of the treatment group.
the bootstrap test to test whether the mean of the
control group is the same as the mean of the treatment group. See Algorithm 16.2
of Efron and Tibshirani (1994).
the permutation test to test whether the distribution of the
control group is the same as the distribution of the treatment group.
See Algorithm 15.1 of Efron and Tibshirani (1994).
A list of absolute lift, relative lift, standardized absolute lift and their corresponding p-values. Standardized absolute lift equals absolute lift divided by its standard deviation. Only absolute lift and relative lift are available for method clt.
Wanjun Liu, Xiufan Yu, Jialiang Mao, Xiaoxu Wu, and Justin Dyer. 2023. Quantifying the Effectiveness of Advertising: A Bootstrap Proportion Test for Brand Lift Testing. In Proceedings of the 32nd ACM International Conference on Information and Knowledge Management (CIKM ’23)
Efron, Bradley, and Robert J. Tibshirani. An introduction to the bootstrap. CRC press, 1994.
n1 <- 100; n2 <- 100; p1 <- 0.1; p2 <- 0.2 set.seed(1) sim.data <- gen.simu.data(n1, n2, p1, p2, summary = TRUE) result <- proportion.test(sim.data, method = "bootstrap", B = 1000) relative.lift <- result$lift$relative relative.lift.pval <- result$pvalue$relative
n1 <- 100; n2 <- 100; p1 <- 0.1; p2 <- 0.2 set.seed(1) sim.data <- gen.simu.data(n1, n2, p1, p2, summary = TRUE) result <- proportion.test(sim.data, method = "bootstrap", B = 1000) relative.lift <- result$lift$relative relative.lift.pval <- result$pvalue$relative