BetaRates-class | R Documentation |
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.
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)
object |
object of class |
br |
object of class |
x |
In the |
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 |
TBD
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).
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.
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.
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.
Plots an image of the posterior probabilities using the specified color map. The point with the maximum posterior probability is marked in red.
Returns the requested quantiles of the posterior distibution of the binomial rate parameter.
Kevin R. Coombes krc@silicovore.com
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.