present_bbfit: Present the summarized posterior results of the Beta-Binomial...

Description Usage Arguments Value Examples

View source: R/beta_binom.R

Description

Outputs a nicely-formatted table suitable for presentations and reports. Especially useful for combining multiple results into a single summary table.

Usage

1
2
3
4
5
6
7
8
9
present_bbfit(
  object,
  conf_interval = TRUE,
  conf_level = 0.95,
  interval_type = c("quantile", "HPD"),
  raw = FALSE,
  fancy_names = TRUE,
  ...
)

Arguments

object

An object of class "beta_binomial_fit" or a list (named or unnamed) of "beta_binomial_fit" objects created by beta_binom().

conf_interval

A logical flag indicating whether to include Bayesian confidence intervals in the generated table.

conf_level

Probability level for credible intervals. 95% by default.

interval_type

Method for computing intervals ("quantile" or "HPD").

raw

A logical flag to return a data frame instead of the character vector produced by knitr::kable. Useful for performing additional data manipulations.

fancy_names

A logical flag to use reader-friendly column names.

...

Arguments to forward to knitr::kable (e.g. format).

Value

A character vector formatted as Markdown, HTML, or LaTeX. The table has the following columns:

Group 1

The total count of trials in group 1.

Group 2

The total count of trials in group 2.

Pr(Success) in Group 1

Point estimate of the probability of success in group 1.

Pr(Success) in Group 2

Point estimate of the probability of success in group 2.

Difference

Pr(Success) in Group 1 - Pr(Success) in Group 2

Relative Risk

How likely trials in group 1 are to succeed relative to group 2.

Odds Ratio

The ratio of the odds of success in group 1 vs odds of success in group 2.

The estimated quantities have credible intervals by default but these can be turned off with the conf_interval argument.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
fake_data <- matrix(c(200, 150, 250, 300), nrow = 2, byrow = TRUE)
colnames(fake_data) <- c('Safe' ,'Dangerous')
rownames(fake_data) <- c('Animals', 'Plants')

fit <- beta_binom(fake_data)
present_bbfit(fit) # uses getOption("digits")
present_bbfit(fit, digits = 2)
present_bbfit(fit, conf_interval = FALSE, digits = 3)
present_bbfit(fit, conf_level = 0.8, interval_type = "HPD", digits = 2)

fit_2 <- update(fit, x = c(8, 4), n = c(10, 50))
fit_3 <- update(fit_2, x = c(1, 20), n = c(15, 40))
fit_4 <- update(fit_3, x = c(20, 13), n = c(80, 45))
present_bbfit(list("Day 1" = fit, "Day 2" = fit_2, "Day 3" = fit_3, "Day 4" = fit_4), digits = 2)

## End(Not run)

bearloga/BCDA documentation built on Feb. 8, 2021, 3:43 p.m.