add_ebb_prop_test: Add columns representing a per-observation proportion test

Description Usage Arguments Examples

Description

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.

Usage

1
2
add_ebb_prop_test(tbl, threshold, alternative = c("greater", "less"),
  sort = FALSE, approx = FALSE)

Arguments

tbl

A table that includes .alpha1 and .beta1 parameters for each observation, typically returned from add_ebb_estimate or from augment.

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.

Examples

 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)

dgrtwo/ebbinom documentation built on May 15, 2019, 7:23 a.m.