Description Usage Arguments Details Value Examples
Assuming n beta distributions, each with parameters a and b, this routine computes the A and B of an overall beta distribution when the n distributions are mixed. Mixing parameters (fractions) can be specified as weights.
1 | mixtureBeta(Ba, Bb, w = NULL)
|
Ba |
A vector containing the alpha parameter for all beta distributions. |
Bb |
A vector containing the beta parameter for all beta distributions. |
w |
A vector indicating the relative weight for each beta distribution
in the mixture distribution. The default is |
The assumption is that each beta distribution is independent of every other, and that they are combined into a composite mixture beta distribution. This routine uses mixture distribution theory to calculate a mean and a variance. The mean and variance are then used in a method of moments approach to calculate the parameters for the composite beta distribution.
A data frame (containing 1 row) with the beta mixture parameter estimates and summary statistics. The compoents (columns) of the returned data frame are:
alpha = alpha parameter of the composite beta distribution,
beta = beta parameter of the composite beta distribution,
mean = mean of the composite beta distribution (alpha/(alpha+beta)),
variance = variance of the composite beta (alpha*beta)/((alpha+beta)^2*(alpha+beta+1)),
lower2.5 = 2.5-th quantile of the composite beta distribution
upper97.5 = 97.5-th quantile of the coomposite beta distribution.
1 2 3 4 5 6 7 8 9 10 11 | ## alpha parameter for the beta distribution
(alpha <- c(100.5,100.5,100.5,235.4,235.4))
## beta parameter for the beta distribution
(beta <- c(234.5,234.5,234.5,2708,2708))
## alpha and beta are assumed to be in the same order
mixtureBeta(Ba=alpha,Bb=beta) ## equal weights
weight <- 1:5
mixtureBeta(Ba=alpha,Bb=beta,w=weight) ## unequal weights
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.