Beta {joker} | R Documentation |
Beta Distribution
Description
The Beta distribution is an absolute continuous probability distribution with
support S = [0,1]
, parameterized by two shape parameters,
\alpha > 0
and \beta > 0
.
Usage
Beta(shape1 = 1, shape2 = 1)
## S4 method for signature 'Beta,numeric'
d(distr, x, log = FALSE)
## S4 method for signature 'Beta,numeric'
p(distr, q, lower.tail = TRUE, log.p = FALSE)
## S4 method for signature 'Beta,numeric'
qn(distr, p, lower.tail = TRUE, log.p = FALSE)
## S4 method for signature 'Beta,numeric'
r(distr, n)
## S4 method for signature 'Beta'
mean(x)
## S4 method for signature 'Beta'
median(x)
## S4 method for signature 'Beta'
mode(x)
## S4 method for signature 'Beta'
var(x)
## S4 method for signature 'Beta'
sd(x)
## S4 method for signature 'Beta'
skew(x)
## S4 method for signature 'Beta'
kurt(x)
## S4 method for signature 'Beta'
entro(x)
## S4 method for signature 'Beta'
finf(x)
llbeta(x, shape1, shape2)
## S4 method for signature 'Beta,numeric'
ll(distr, x)
ebeta(x, type = "mle", ...)
## S4 method for signature 'Beta,numeric'
mle(
distr,
x,
par0 = "same",
method = "L-BFGS-B",
lower = 1e-05,
upper = Inf,
na.rm = FALSE
)
## S4 method for signature 'Beta,numeric'
me(distr, x, na.rm = FALSE)
## S4 method for signature 'Beta,numeric'
same(distr, x, na.rm = FALSE)
vbeta(shape1, shape2, type = "mle")
## S4 method for signature 'Beta'
avar_mle(distr)
## S4 method for signature 'Beta'
avar_me(distr)
## S4 method for signature 'Beta'
avar_same(distr)
Arguments
shape1 , shape2 |
numeric. The non-negative distribution parameters. |
distr |
an object of class |
x |
For the density function, |
log , log.p |
logical. Should the logarithm of the probability be returned? |
q |
numeric. Vector of quantiles. |
lower.tail |
logical. If TRUE (default), probabilities are
|
p |
numeric. Vector of probabilities. |
n |
number of observations. If |
type |
character, case ignored. The estimator type (mle, me, or same). |
... |
extra arguments. |
par0 , method , lower , upper |
arguments passed to optim for the mle optimization. See Details. |
na.rm |
logical. Should the |
Details
The probability density function (PDF) of the Beta distribution is given by:
f(x; \alpha, \beta) = \frac{x^{\alpha - 1} (1 - x)^{\beta -
1}}{B(\alpha, \beta)},
\quad \alpha\in\mathbb{R}_+, \, \beta\in\mathbb{R}_+,
for x \in S = [0, 1]
, where B(\alpha, \beta)
is the Beta
function:
B(\alpha, \beta) = \int_0^1 t^{\alpha - 1} (1 - t)^{\beta - 1} dt.
The MLE of the beta distribution parameters is not available in closed form
and has to be approximated numerically. This is done with optim()
.
Specifically, instead of solving a bivariate optimization problem w.r.t
(\alpha, \beta)
, the optimization can be performed on the parameter
sum \alpha_0:=\alpha + \beta \in(0,+\infty)
. The default method used
is the L-BFGS-B method with lower bound 1e-5
and upper bound Inf
. The
par0
argument can either be a numeric (satisfying lower <= par0 <= upper
)
or a character specifying the closed-form estimator to be used as
initialization for the algorithm ("me"
or "same"
- the default value).
Value
Each type of function returns a different type of object:
Distribution Functions: When supplied with one argument (
distr
), thed()
,p()
,q()
,r()
,ll()
functions return the density, cumulative probability, quantile, random sample generator, and log-likelihood functions, respectively. When supplied with both arguments (distr
andx
), they evaluate the aforementioned functions directly.Moments: Returns a numeric, either vector or matrix depending on the moment and the distribution. The
moments()
function returns a list with all the available methods.Estimation: Returns a list, the estimators of the unknown parameters. Note that in distribution families like the binomial, multinomial, and negative binomial, the size is not returned, since it is considered known.
Variance: Returns a named matrix. The asymptotic covariance matrix of the estimator.
References
Tamae, H., Irie, K. & Kubokawa, T. (2020), A score-adjusted approach to closed-form estimators for the gamma and beta distributions, Japanese Journal of Statistics and Data Science 3, 543–561.
Papadatos, N. (2022), On point estimators for gamma and beta distributions, arXiv preprint arXiv:2205.10799.
See Also
Functions from the stats
package: dbeta()
, pbeta()
, qbeta()
,
rbeta()
Examples
# -----------------------------------------------------
# Beta Distribution Example
# -----------------------------------------------------
# Create the distribution
a <- 3
b <- 5
D <- Beta(a, b)
# ------------------
# dpqr Functions
# ------------------
d(D, c(0.3, 0.8, 0.5)) # density function
p(D, c(0.3, 0.8, 0.5)) # distribution function
qn(D, c(0.4, 0.8)) # inverse distribution function
x <- r(D, 100) # random generator function
# alternative way to use the function
df <- d(D) ; df(x) # df is a function itself
# ------------------
# Moments
# ------------------
mean(D) # Expectation
var(D) # Variance
sd(D) # Standard Deviation
skew(D) # Skewness
kurt(D) # Excess Kurtosis
entro(D) # Entropy
finf(D) # Fisher Information Matrix
# List of all available moments
mom <- moments(D)
mom$mean # expectation
# ------------------
# Point Estimation
# ------------------
ll(D, x)
llbeta(x, a, b)
ebeta(x, type = "mle")
ebeta(x, type = "me")
ebeta(x, type = "same")
mle(D, x)
me(D, x)
same(D, x)
e(D, x, type = "mle")
mle("beta", x) # the distr argument can be a character
# ------------------
# Estimator Variance
# ------------------
vbeta(a, b, type = "mle")
vbeta(a, b, type = "me")
vbeta(a, b, type = "same")
avar_mle(D)
avar_me(D)
avar_same(D)
v(D, type = "mle")