View source: R/betabinmoments.R
betabinmoments | R Documentation |
Calculates the first four central moments as well as skewness and kurtosis from two different parametrizations
betabinmoments(alpha = NULL, beta = NULL,
pi = NULL, rho = NULL,
size)
alpha |
numeric > 0. Parameter (see Details). |
beta |
numeric > 0. Parameter (see Details). |
pi |
numeric. Parameter between 0 and 1 (see Details and |
rho |
numeric. Parameter between 0 and 1 (see Details and |
size |
integer. Parameter (number of trials). |
The user needs to supply either alpha
and beta
or pi
and rho
. In either case n
(= size
) is the number of trials. In the parametrization using alpha
and beta
, the mean and variance are given by n\frac{\alpha}{\alpha + \beta}
and n\alpha\beta(\alpha+\beta+n)/((\alpha+\beta)^2(\alpha+\beta+1))
respectively. If rho
and pi
are supplied, the mean and variance of the Beta-binomial distributions are given by the expressions stated in the documentation of bbm
.
A list with components
mean |
mean |
variance |
variance |
skewness |
skewness |
kurtosis |
kurtosis |
mu3 |
third central moment |
mu4 |
fourth central moment |
Both parametrizations are related by the following relations:
\pi = \frac{\alpha}{\alpha + \beta}
and
\rho = \frac{1}{\alpha+\beta+1}.
Philipp Doebler <philipp.doebler@googlemail.com>
bbm
# Example 1: alpha and beta as parameters
alpha <- 4.5
beta <- 4.5
betabinmoments(alpha, beta, size = 12)
# Example 2: calculte pi and rho:
pi <- alpha/(alpha + beta) # 0.5
rho <- 1/(alpha + beta + 1) # 0.1
betabinmoments(pi = pi, rho = rho, size = 12)
# the same moments result
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.