Description Usage Arguments Examples
Run on the result of add_ebb_estimate
, or of augment
on an ebb_prior object from ebb_fit_prior
. This adds columns with the
posterior error probability (PEP) and the qvalue.
1 2 |
tbl |
A table that includes .alpha1 and .beta1 parameters for each
observation, typically returned from |
threshold |
The proportion to which each observation is compared. |
alternative |
Alternative hypothesis. For example, if the alternative is "greater", the PEP will be the posterior probability that the true value is lower than the threshold. |
sort |
Optionally, whether to sort the table in order of ascending posterior error probability. |
approx |
Whether to use a normal approximation to the beta. Used only when comparing to another beta. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(dplyr)
set.seed(2017)
obs <- 1000
dat <- data_frame(prob = rbeta(obs, 10, 40),
total = round(rlnorm(obs, 6, 2)) + 1,
x = rbinom(obs, total, prob))
eb <- add_ebb_estimate(dat, x, total)
add_ebb_prop_test(eb, .25)
add_ebb_prop_test(eb, .25, sort = TRUE)
add_ebb_prop_test(eb, .3, sort = TRUE)
add_ebb_prop_test(eb, .4, sort = TRUE)
# comparing the actual p to the posterior probability
# that p is under .25
library(ggplot2)
ggplot(add_ebb_prop_test(eb, .25), aes(prob, .pep, color = log10(total))) +
geom_point() +
geom_vline(xintercept = .25, color = "red", lty = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.