Geom {joker}R Documentation

Geometric Distribution

Description

The Geometric distribution is a discrete probability distribution that models the number of failures before the first success in a sequence of independent Bernoulli trials, each with success probability 0 < p \leq 1.

Usage

Geom(prob = 0.5)

## S4 method for signature 'Geom,numeric'
d(distr, x, log = FALSE)

## S4 method for signature 'Geom,numeric'
p(distr, q, lower.tail = TRUE, log.p = FALSE)

## S4 method for signature 'Geom,numeric'
qn(distr, p, lower.tail = TRUE, log.p = FALSE)

## S4 method for signature 'Geom,numeric'
r(distr, n)

## S4 method for signature 'Geom'
mean(x)

## S4 method for signature 'Geom'
median(x)

## S4 method for signature 'Geom'
mode(x)

## S4 method for signature 'Geom'
var(x)

## S4 method for signature 'Geom'
sd(x)

## S4 method for signature 'Geom'
skew(x)

## S4 method for signature 'Geom'
kurt(x)

## S4 method for signature 'Geom'
entro(x)

## S4 method for signature 'Geom'
finf(x)

llgeom(x, prob)

## S4 method for signature 'Geom,numeric'
ll(distr, x)

egeom(x, type = "mle", ...)

## S4 method for signature 'Geom,numeric'
mle(distr, x, na.rm = FALSE)

## S4 method for signature 'Geom,numeric'
me(distr, x, na.rm = FALSE)

vgeom(prob, type = "mle")

## S4 method for signature 'Geom'
avar_mle(distr)

## S4 method for signature 'Geom'
avar_me(distr)

Arguments

prob

numeric. Probability of success.

distr

an object of class Geom.

x

For the density function, x is a numeric vector of quantiles. For the moments functions, x is an object of class Geom. For the log-likelihood and the estimation functions, x is the sample of observations.

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(X \leq x), otherwise P(X > x).

p

numeric. Vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

type

character, case ignored. The estimator type (mle or me).

...

extra arguments.

na.rm

logical. Should the NA values be removed?

Details

The probability mass function (PMF) of the Geometric distribution is:

P(X = k) = (1 - p)^k p, \quad k \in \mathbb{N}_0.

Value

Each type of function returns a different type of object:

See Also

Functions from the stats package: dgeom(), pgeom(), qgeom(), rgeom()

Examples

# -----------------------------------------------------
# Geom Distribution Example
# -----------------------------------------------------

# Create the distribution
p <- 0.4
D <- Geom(p)

# ------------------
# dpqr Functions
# ------------------

d(D, 0:4) # density function
p(D, 0:4) # 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
median(D) # Median
mode(D) # Mode
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)
llgeom(x, p)

egeom(x, type = "mle")
egeom(x, type = "me")

mle(D, x)
me(D, x)
e(D, x, type = "mle")

mle("geom", x) # the distr argument can be a character

# ------------------
# Estimator Variance
# ------------------

vgeom(p, type = "mle")
vgeom(p, type = "me")

avar_mle(D)
avar_me(D)

v(D, type = "mle")

[Package joker version 0.14.2 Index]