Description Usage Arguments Details Author(s) Examples
View source: R/plot_posterior.R
Function for plotting the posterior distribution.
1 2 3 4 5 6 7 8 9 10 11 | plot_posterior(
x,
what = "logor",
hypothesis = "H1",
ci = 0.95,
p1lab = "p1",
p2lab = "p2",
p1adj = 0.44,
p2adj = 0.56,
...
)
|
x |
object of class |
what |
character specifying for which quantity the posterior should be
plotted. Either |
hypothesis |
character specifying whether to plot the two-sided posterior distribution (i.e., "H1"), the one-sided posterior distribution with lower truncation point (i.e., "H+"), or the one-sided posterior distribution with upper truncation point (i.e., "H-"). |
ci |
numeric value specifying the |
p1lab |
determines p1 x-axis label. Only relevant for |
p2lab |
determines p2 x-axis label. Only relevant for |
p1adj |
determines p1 x-axis label adjustment. Only relevant for
|
p2adj |
determines p2 x-axis label adjustment. Only relevant for
|
... |
further arguments |
The resulting plot displays the posterior density for the quantitiy
of interest and also displays the corresponding prior density. The values
of the posterior median and a ci
% central credible interval are
displayed on top of the plot.
Quentin F. Gronau
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # synthetic data
data <- list(y1 = 10, n1 = 28, y2 = 14, n2 = 26)
# Bayesian A/B test with default settings
ab <- ab_test(data = data, posterior = TRUE)
# plot parameter posterior
plot_posterior(x = ab, what = "logor")
plot_posterior(x = ab, what = "or")
plot_posterior(x = ab, what = "p1p2")
plot_posterior(x = ab, what = "rrisk")
plot_posterior(x = ab, what = "arisk")
# example of good width and height values for saving to file
cairo_pdf(file.path(tempdir(), "test_plot.pdf"),
width = 530 / 72, height = 400 / 72)
plot_posterior(ab, what = "p1p2")
dev.off()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.