Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

epi.betabuster

An R version of Wes Johnson and Chun-Lung Su's Betabuster


Description

A function to return shape1 and shape2 parameters for a beta distribution, based on expert elicitation.

Usage

epi.betabuster(mode, conf, greaterthan, x, conf.level = 0.95, max.shape1 = 100, 
   step = 0.001)

Arguments

mode

scalar, the mode of the variable of interest. Must be a number between 0 and 1.

conf

level of confidence (expressed on a 0 to 1 scale) that the true value of the variable of interest is greater or less than argument x.

greaterthan

logical, if TRUE you are making the statement that you are conf confident that the true value of the variable of interest is greater than x. If FALSE you are making the statement that you are conf confident that the true value of the variable of interest is less than x.

x

scalar, value of the variable of interest (see above).

conf.level

magnitude of the returned confidence interval for the estimated beta distribution. Must be a single number between 0 and 1.

max.shape1

scalar, maximum value of the shape1 parameter for the beta distribution.

step

scalar, step value for the shape1 parameter. See details.

Details

The beta distribution has two parameters: shape1 and shape2, corresponding to a and b in the original verion of BetaBuster. If r equals the number of times an event has occurred after n trials, shape1 = (r + 1) and shape2 = (n - r + 1).

Value

A list containing the following:

shape1

the shape1 parameter for the estimated beta distribution.

shape2

the shape2 parameter for the estimated beta distribution.

mode

the mode of the estimated beta distribution.

mean

the mean of the estimated beta distribution.

median

the median of the estimated beta distribution.

lower

the lower bound of the confidence interval of the estimated beta distribution.

upper

the upper bound of the confidence interval of the estimated beta distribution.

variance

the variance of the estimated beta distribution.

Author(s)

Simon Firestone (Faculty of Veterinary and Agricultural Sciences, The University of Melbourne, Australia) with acknowledgements to Wes Johnson and Chun-Lung Su for the original standalone software.

References

Christensen R, Johnson W, Branscum A, Hanson TE (2010). Bayesian Ideas and Data Analysis: An Introduction for Scientists and Statisticians. Chapman and Hall, Boca Raton.

Examples

## EXAMPLE 1:
## If a scientist is asked for their best guess for the diagnostic sensitivity
## of a particular test and the answer is 0.90, and if they are also willing 
## to assert that they are 80% certain that the sensitivity is greater than 
## 0.75, what are the shape1 and shape2 parameters for a beta distribution
## satisfying these constraints? 

rval <- epi.betabuster(mode = 0.90, conf = 0.80, greaterthan = TRUE, 
   x = 0.75, conf.level = 0.95, max.shape1 = 100, step = 0.001)
rval$shape1; rval$shape2

## The shape1 and shape2 parameters for the beta distribution that satisfy the
## constraints listed above are 9.875 and 1.986, respectively.

## This beta distribution reflects the probability distribution 
## obtained if there were 9 successes, r:
r <- rval$shape1 - 1; r

## from 10 trials, n:
n <- rval$shape2 + rval$shape1 - 2; n

dat <- data.frame(x = seq(from = 0, to = 1, by = 0.001), 
   y = dbeta(x = seq(from = 0, to = 1,by = 0.001), 
   shape1 = rval$shape1, shape2 = rval$shape2))

## Density plot of the estimated beta distribution:

## Not run: 
library(ggplot2)

ggplot(data = dat, aes(x = x, y = y)) +
   geom_line() + 
   scale_x_continuous(name = "Test sensitivity") +
   scale_y_continuous(name = "Density")

## End(Not run)

epiR

Tools for the Analysis of Epidemiological Data

v2.0.19
GPL (>= 2)
Authors
Mark Stevenson <mark.stevenson1@unimelb.edu.au> and Evan Sergeant <evansergeant@gmail.com> with contributions from Telmo Nunes, Cord Heuer, Jonathon Marshall, Javier Sanchez, Ron Thornton, Jeno Reiczigel, Jim Robison-Cox, Paola Sebastiani, Peter Solymos, Kazuki Yoshida, Geoff Jones, Sarah Pirikahu, Simon Firestone, Ryan Kyle, Johann Popp, Mathew Jay and Charles Reynard.
Initial release
2021-01-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.