Description Usage Arguments Examples
This intended as a black-box example with a small data set to illustrate the results of Bayesian updating. The model is a Bernoulli model with fixed proportion over all trials. Prior, data, and grid resolution can be supplied by the user. See 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 | BernGrid(
data = "HHTT",
p = seq(0, 1, length.out = resolution + 1),
prior = 1,
results = c("plot", "data"),
steps = FALSE,
geom = if (length(p) <= 20) geom_col else geom_area,
alpha = 0.5,
resolution = 200,
filter = TRUE,
...
)
bern_grid(
data = "HHTT",
p = seq(0, 1, length.out = resolution + 1),
prior = 1,
results = c("plot", "data"),
steps = FALSE,
geom = if (length(p) <= 20) geom_col else geom_area,
alpha = 0.5,
resolution = 200,
filter = TRUE,
...
)
|
data |
a vector of 0's and 1's or a character string with two characters representing success/failure or head/tails from the bernoulli experiment. |
p |
a vector of probabilites to update. |
prior |
a vector of prior values at each probability in |
results |
either |
steps |
a logical indicating wether the process should be shown step-by-step or for all the data at once. |
geom |
a geom used for plotting. Good choices include
|
alpha |
opacity used for the plot |
resolution |
if |
filter |
an expression used to filter the results. See examples. |
... |
additional arguments passed to the geom. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | BernGrid("HHTTH", p = seq(0, 1, by = 0.25), results = "data")
BernGrid("HHTTH",
prior = ~ dbeta(.x, shape1 = 2, shape2 = 5))
BernGrid("HHTTH", geom = geom_col, resolution = 100,
prior = ~ dbeta(.x, shape1 = 2, shape2 = 5))
BernGrid("HHTTH", geom = geom_area, resolution = 100,
prior = ~ dbeta(.x, shape1 = 2, shape2 = 5))
BernGrid("HHTTH",
p = seq(0, 1, by = 0.25), prior = c(.1, .2 , .4, .2, .1))
BernGrid("SSFFS", p = seq(0, 1, by = 0.25), steps = TRUE, results = "data")
BernGrid("SSFFS", p = seq(0, 1, by = 0.25), alpha = 0.9, steps = TRUE)
BernGrid("SSFFS", p = seq(0, 1, by = 0.25), alpha = 0.5, steps = TRUE,
filter = n %in% c(4,5))
BernGrid("HHTTHTHHTHHH", alpha = 0.9, steps = TRUE)
BernGrid("HHTTHTHHTHHH", steps = TRUE, geom = geom_area)
BernGrid("HHTTHTHHTHHH", alpha = 0.9, steps = TRUE, filter = n %in% c(1, 5, 10))
BernGrid("HHTTHTHHTHHH", alpha = 0.9, steps = TRUE, filter = n == 10)
# same posterior as in the previous example -- order doesn't matter
BernGrid("TTTTHHHHHHHH", alpha = 0.9, steps = TRUE, filter = n == 10)
BernGrid("HHHHHHHHHHHH", alpha = 0.9)
BernGrid("HHHHHHHHHHHH", alpha = 0.9, steps = TRUE)
BernGrid(rbinom(12, 1, 0.25), alpha = 0.9, steps = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.