BetaRates: Class "BetaRates"

View source: R/00-basics.R

BetaRates-classR Documentation

Class "BetaRates"

Description

Test for different proportions (rates) in different groups using a Bayesian model in which all rate parameters follow a beta distribution and are selected from a common hyperdistribution.

Usage

BetaRates(k, n, x=seq(-3,3, length=100), y=x)
## S4 method for signature 'BetaRates'
summary(object, ...)
## S4 method for signature 'BetaRates'
image(x, col=greyscale(128), ...)
## S4 method for signature 'BetaRates'
quantile(x, probs, ...)
samplePosteriorRates(br, nsamp=2000)
expectation(br)
guessCenter(v)

Arguments

object

object of class BetaRates

br

object of class BetaRates

x

In the image and quantile methods, an object of class BetaRates. In the BetaRates constructor, a vector of the x-axis grid points at which to compute the posterior probability; see Details.

y

vector of the y-axis grid points at which to compute the posterior probability; see Details.

k

vector of "success" counts

n

vector of all counts

col

vector containing the color map to use for the image

probs

vector of wuantiles to be returned

nsamp

Number of posterior samples to take

v

Vector of observed rates

...

extra arguments for generic routines

Details

TBD

Value

The BetaRates constructor returns an object of the indicated class.

The graphical method image invisibly returns the object on which it was invoked.

The summary method returns a vector with the maximum a posteriori parameters of the beta distribution.

The samplePosteriorRates function returns a list with two components. The first component, xy, is an nsamp-by-2 matrix with x-y values samples from the posterior distribution. The second component, theta, is an nsamp-by-length(k) matrix with posterior samples of the rates associated with each experiment supplied to the constructor.

The guessCenter function returns a list with both x-y and alpha-beta coordinates of the naive (frequentist) estimate of the overall Beta distribution parameters.

The expectation function returns the maximum posterior values from the model. This includes the coordinates (x, y), the transformed coordinates (alpha, beta), the mean (alpha/beta) and the size (alpha + beta).

Creating Objects

Although objects can be created directly using new, the most common usage will be to pass a vector of p-values to the BetaRates function.

Slots

k:

vector of "success" counts.

n:

vector of all counts.

x:

vector of the x-axis grid points at which to compute the posterior probability; see Details.

y:

vector of the y-axis grid points at which to compute the posterior probability; see Details.

results:

Matrix of posterior probabilities.

logresults:

Matrix of log-transformed posterior probabilities.

Methods

summary(object, ...)

Prints a summary of the BetaRates object. This includes (1) the maximum a posterior coordinates on x-y-space, (2) the usual alpha-beta parameters for the Beta distribution, and (3) the mean and variance.

image(x, col, ...)

Plots an image of the posterior probabilities using the specified color map. The point with the maximum posterior probability is marked in red.

quantile(x, probs, ...)

Returns the requested quantiles of the posterior distibution of the binomial rate parameter.

Author(s)

Kevin R. Coombes krc@silicovore.com

References

Gelman A, Carlin JB, Stern HS, Rubin DB. Bayesian Data Analysis, second edition. Chapman and Hall/CRC, Boca Raton, 2004. Section 5.3, pages 15-131.

Examples

showClass("BetaRates")
event <- c( 37,  4,  6,  1,  2, 10,  1, 13,   7,  1,  10)
total <- c(137, 18, 18, 26, 24, 45, 12, 43, 162, 78, 280)
guessCenter(event/total)
br <- BetaRates(event, total, x=seq(-3, 0, length=100), y=seq(0, 3, length=100))
image(br)
summary(br)

BetaModels documentation built on Feb. 9, 2024, 3:01 a.m.