Cauchy {joker}R Documentation

Cauchy Distribution

Description

The Cauchy distribution is an absolute continuous probability distribution characterized by its location parameter x_0 and scale parameter \gamma > 0.

Usage

Cauchy(location = 0, scale = 1)

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

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

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

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

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

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

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

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

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

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

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

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

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

llcauchy(x, location, scale)

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

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

## S4 method for signature 'Cauchy,numeric'
mle(
  distr,
  x,
  par0 = "me",
  method = "L-BFGS-B",
  lower = c(-Inf, 1e-05),
  upper = c(Inf, Inf),
  na.rm = FALSE
)

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

vcauchy(location, scale, type = "mle")

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

Arguments

location, scale

numeric. Location and scale parameters.

distr

an object of class Cauchy.

x

For the density function, x is a numeric vector of quantiles. For the moments functions, x is an object of class Cauchy. 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.

par0, method, lower, upper

arguments passed to optim for the mle optimization.

na.rm

logical. Should the NA values be removed?

Details

The probability density function (PDF) of the Cauchy distribution is given by:

f(x; x_0, \gamma) = \frac{1}{\pi \gamma \left[1 + \left(\frac{x - x_0}{\gamma}\right)^2\right]}.

The MLE of the Cauchy distribution parameters is not available in closed form and has to be approximated numerically. This is done with optim(). The default method used is the L-BFGS-B method with lower bounds c(-Inf, 1e-5) and upper bounds c(Inf, Inf). The par0 argument can either be a numeric (both elements satisfying ⁠lower <= par0 <= upper⁠) or a character specifying the closed-form estimator to be used as initialization for the algorithm ("me" - the default value).

Note that the me() estimator for the Cauchy distribution is not a moment estimator; it utilizes the sample median instead of the sample mean.

Value

Each type of function returns a different type of object:

See Also

Functions from the stats package: dcauchy(), pcauchy(), qcauchy(), rcauchy()

Examples

# -----------------------------------------------------
# Cauchy Distribution Example
# -----------------------------------------------------

# Create the distribution
x0 <- 3 ; scale <- 5
D <- Cauchy(x0, scale)

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

d(D, c(-5, 3, 10)) # density function
p(D, c(-5, 3, 10)) # 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
# ------------------

median(D) # Median
mode(D) # Mode
entro(D) # Entropy
finf(D) # Fisher Information Matrix

# ------------------
# Point Estimation
# ------------------

ll(D, x)
llcauchy(x, x0, scale)

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

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

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

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

vcauchy(x0, scale, type = "mle")
avar_mle(D)
v(D, type = "mle")

[Package joker version 0.14.2 Index]