plot_sequential {abtest} | R Documentation |
Plot Sequential Analysis
Description
Function for plotting the posterior probabilities of the hypotheses sequentially.
Usage
plot_sequential(x, thin = 1, cores = 1, ...)
Arguments
x |
object of class |
thin |
allows the user to skip every |
cores |
number of cores used for the computations. |
... |
further arguments |
Details
The plot shows the posterior probabilities of the hypotheses as a
function of the total number of observations across the experimental and
control group. On top of the plot, probability wheels (see also
prob_wheel
) visualize the prior probabilities of the
hypotheses and the posterior probabilities of the hypotheses after taking
into account all available data.
N.B.: This plot has been designed to look good in the following format: In inches, 530 / 72 (width) by 400 / 72 (height); in pixels, 530 (width) by 400 (height).
Author(s)
Quentin F. Gronau
Examples
### 1.
# synthetic sequential data (observations alternate between the groups)
# note that the cumulative number of successes and trials need to be provided
data <- list(y1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4),
n1 = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10),
y2 = c(0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9),
n2 = c(0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10))
# conduct Bayesian A/B test with default settings
ab <- ab_test(data = data)
print(ab)
# produce sequential plot of posterior probabilities of the hypotheses
# (using recommended width and height values for saving to file)
cairo_pdf(file.path(tempdir(), "test_plot.pdf"),
width = 530 / 72, height = 400 / 72)
plot_sequential(ab)
dev.off()
### 2.
# synthetic sequential data (observations alternate between the groups)
# this time provided in the alternative format
data2 <- data.frame(outcome = c(1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 1, 1, 1, 1, 1, 0),
group = rep(c(1, 2), 10))
# conduct Bayesian A/B test with default settings
ab2 <- ab_test(data = data2)
print(ab2)
# produce sequential plot of posterior probabilities of the hypotheses
# (using recommended width and height values for saving to file)
cairo_pdf(file.path(tempdir(), "test_plot2.pdf"),
width = 530 / 72, height = 400 / 72)
plot_sequential(ab2)
dev.off()
## Not run:
### 3.
data(seqdata)
# conduct Bayesian A/B test with default settings
ab3 <- ab_test(data = seqdata)
print(ab3)
# produce sequential plot of posterior probabilities of the hypotheses
# (using recommended width and height values for saving to file)
cairo_pdf(file.path(tempdir(), "test_plot3.pdf"),
width = 530 / 72, height = 400 / 72)
plot_sequential(ab3, thin = 4)
dev.off()
## End(Not run)