Learn R Programming

joker (version 0.14.2)

functionals: Distribution Functionals

Description

A collection of S4 classes that provide a flexible and structured way to work with probability distributions.

Usage

# S4 method for Distribution,missing
d(distr, x, ...)

# S4 method for Distribution,missing p(distr, q, ...)

# S4 method for Distribution,missing qn(distr, p, ...)

# S4 method for Distribution,missing r(distr, n, ...)

# S4 method for Distribution,missing ll(distr, x, ...)

# S4 method for Distribution,missing mle(distr, x, ...)

# S4 method for Distribution,missing me(distr, x, ...)

# S4 method for Distribution,missing same(distr, x, ...)

Value

When supplied with one argument, the d(), p(), q(), r()

ll()

functions return the density, cumulative probability, quantile, random sample generator, and log-likelihood functions, respectively.

Arguments

distr

a Distribution object.

x, q, p, n

missing. Arguments not supplied.

...

extra arguments.

Details

When x, q, p, or n are missing, the methods return a function that takes as input the missing argument, allowing the user to work with the function object itself. See examples.

See Also

moments, loglikelihood, estimation, Bern, Beta, Binom, Cat, Cauchy, Chisq, Dir, Exp, Fisher, Gam, Geom, Laplace, Lnorm, Multigam, Multinom, Nbinom, Norm, Pois, Stud, Unif, Weib

Examples

Run this code
# -----------------------------------------------------
# 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")

Run the code above in your browser using DataLab