This set of functions estimates the parameters of a random sample according to a specified family of distributions. See details.
Usage
e(distr, x, type = "mle", ...)
mle(distr, x, ...)
# S4 method for class 'character,ANY'
mle(distr, x, ...)
me(distr, x, ...)
# S4 method for class 'character,ANY'
me(distr, x, ...)
same(distr, x, ...)
# S4 method for class 'character,ANY'
same(distr, x, ...)
Value
list. The estimator 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.
Details
The package covers three major estimation methods: maximum likelihood estimation (MLE), moment estimation (ME), and score-adjusted estimation (SAME).
In order to perform parameter estimation, a new e<name>()
member is added
to the d()
, p()
, q()
, r()
family, following the standard stats
name
convention. These functions take two arguments, the observations x
(an
atomic vector for univariate or a matrix for multivariate distributions) and
the type
of estimation method to use (a character with possible values
"mle"
, "me"
, and "same"
.)
Point estimation functions are available in two versions, the distribution
specific one, e.g. ebeta()
, and the S4 generic ones, namely mle()
,
me()
, and same()
. A general function called e()
is also implemented,
covering all distributions and estimators.
Functions
mle()
: Maximum Likelihood Estimatorme()
: Moment Estimatorsame()
: Score - Adjusted Moment Estimation
References
General Textbooks
Van der Vaart, A. W. (2000), Asymptotic statistics, Vol. 3, Cambridge university press.
Beta and gamma distribution families
Ye, Z.-S. & Chen, N. (2017), Closed-form estimators for the gamma distribution derived from likelihood equations, The American Statistician 71(2), 177–181.
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.
Mathal, A. & Moschopoulos, P. (1992), A form of multivariate gamma distribution, Annals of the Institute of Statistical Mathematics 44, 97–106.
Oikonomidis, I. & Trevezas, S. (2023), Moment-Type Estimators for the Dirichlet and the Multivariate Gamma Distributions, arXiv, https://arxiv.org/abs/2311.15025
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
#> [1] 2.268945 0.107520 1.640625
p(D, c(0.3, 0.8, 0.5)) # distribution function
#> [1] 0.3529305 0.9953280 0.7734375
qn(D, c(0.4, 0.8)) # inverse distribution function
#> [1] 0.3205858 0.5167578
x <- r(D, 100) # random generator function
# alternative way to use the function
df <- d(D) ; df(x) # df is a function itself
#> [1] 1.4198971 2.3026811 2.1527876 2.1559828 2.2952240 1.4998853 1.1787365
#> [8] 2.2698479 1.8325384 1.4823383 0.5134081 2.1501205 1.4832977 1.9415785
#> [15] 2.0739930 1.2975502 1.0864139 2.0698490 2.3008319 0.9729585 1.3533122
#> [22] 1.1679036 1.0766764 1.8842418 1.3777491 0.5970010 1.9569397 0.5283950
#> [29] 2.2894999 1.0217671 1.9408534 1.5536234 1.7338556 2.2814904 1.6143634
#> [36] 0.2261083 2.1603232 2.0614949 2.2266758 1.9726484 1.8939718 1.8590425
#> [43] 2.1122940 1.0266288 2.2899148 2.0001139 2.2696280 1.1425762 1.8437480
#> [50] 1.2960753 0.9354456 2.1810083 0.3213871 1.0859118 1.0760938 0.8695952
#> [57] 0.6928323 2.0152561 2.3024280 1.5612256 2.2571190 1.8835831 1.5722668
#> [64] 1.9218629 1.9996474 2.2849652 1.9021439 2.1330371 0.5768307 2.2143324
#> [71] 2.3005903 2.2313742 1.9132474 0.6324472 1.2426860 1.6216604 1.0566885
#> [78] 2.1700193 0.6268517 1.3252982 1.7557286 2.3041119 2.1369220 1.1256808
#> [85] 2.0452147 2.2706022 2.0058652 1.3053960 0.6486066 1.8293846 1.9926417
#> [92] 2.1203136 2.2789298 2.0563792 0.5056378 2.0173575 1.0181820 2.2272335
#> [99] 0.1097897 2.2036227
# ------------------
# Moments
# ------------------
mean(D) # Expectation
#> [1] 0.375
var(D) # Variance
#> [1] 0.02604167
sd(D) # Standard Deviation
#> [1] 0.1613743
skew(D) # Skewness
#> [1] 0.3098387
kurt(D) # Excess Kurtosis
#> [1] 0.04
entro(D) # Entropy
#> [1] -0.4301508
finf(D) # Fisher Information Matrix
#> shape1 shape2
#> shape1 0.2617971 -0.13313701
#> shape2 -0.1331370 0.08818594
# List of all available moments
mom <- moments(D)
mom$mean # expectation
#> [1] 0.375
# ------------------
# Point Estimation
# ------------------
ll(D, x)
#> [1] 38.82471
llbeta(x, a, b)
#> [1] 38.82471
ebeta(x, type = "mle")
#> $shape1
#> [1] 2.726376
#>
#> $shape2
#> [1] 4.534167
#>
ebeta(x, type = "me")
#> $shape1
#> [1] 2.728009
#>
#> $shape2
#> [1] 4.514866
#>
ebeta(x, type = "same")
#> $shape1
#> [1] 2.721989
#>
#> $shape2
#> [1] 4.504902
#>
mle(D, x)
#> $shape1
#> [1] 2.726376
#>
#> $shape2
#> [1] 4.534167
#>
me(D, x)
#> $shape1
#> [1] 2.728009
#>
#> $shape2
#> [1] 4.514866
#>
same(D, x)
#> $shape1
#> [1] 2.721989
#>
#> $shape2
#> [1] 4.504902
#>
e(D, x, type = "mle")
#> $shape1
#> [1] 2.726376
#>
#> $shape2
#> [1] 4.534167
#>
mle("beta", x) # the distr argument can be a character
#> $shape1
#> [1] 2.726376
#>
#> $shape2
#> [1] 4.534167
#>
# ------------------
# Estimator Variance
# ------------------
vbeta(a, b, type = "mle")
#> shape1 shape2
#> shape1 16.44844 24.83272
#> shape2 24.83272 48.83039
vbeta(a, b, type = "me")
#> shape1 shape2
#> shape1 17.64848 26.56970
#> shape2 26.56970 51.39394
vbeta(a, b, type = "same")
#> shape1 shape2
#> shape1 16.57719 24.96198
#> shape2 24.96198 49.01071
avar_mle(D)
#> shape1 shape2
#> shape1 16.44844 24.83272
#> shape2 24.83272 48.83039
avar_me(D)
#> shape1 shape2
#> shape1 17.64848 26.56970
#> shape2 26.56970 51.39394
avar_same(D)
#> shape1 shape2
#> shape1 16.57719 24.96198
#> shape2 24.96198 49.01071
v(D, type = "mle")
#> shape1 shape2
#> shape1 16.44844 24.83272
#> shape2 24.83272 48.83039