skellam {skellam}R Documentation

The Skellam Distribution

Description

Density, distribution function, quantile function, and random generation for the Skellam distribution.

Usage

dskellam(x, lambda1, lambda2 = lambda1, log = FALSE)

dskellam.sp(x, lambda1, lambda2 = lambda1, log = FALSE)

pskellam(q, lambda1, lambda2 = lambda1, lower.tail = TRUE, log.p = FALSE)

pskellam.sp(q, lambda1, lambda2 = lambda1, lower.tail = TRUE, log.p = FALSE)

qskellam(p, lambda1, lambda2 = lambda1, lower.tail = TRUE, log.p = FALSE)

rskellam(n, lambda1, lambda2 = lambda1)

Arguments

x, q

For functions dskellam, dskellam.sp, and pskellam.sp: a numeric vector of quantiles.

lambda1, lambda2

Numeric vectors of (non-negative) means; lambda2 defaults to lambda1 if not provided.

log, log.p

Logical; if TRUE, returns the logarithm of the computed value.

lower.tail

Logical; if TRUE (default), returns P(X \le x); otherwise, returns P(X > x).

p

For qskellam: a numeric vector of probabilities.

n

For rskellam: a non-negative integer specifying the number of observations.

Details

The Skellam distribution describes the difference between two independent Poisson random variables. This documentation covers:

Density:

dskellam(x, lambda1, lambda2 = lambda1, log = FALSE)

Distribution Function:

pskellam(q, lambda1, lambda2 = lambda1, lower.tail = TRUE, log.p = FALSE)

Quantile Function:

qskellam(p, lambda1, lambda2 = lambda1, lower.tail = TRUE, log.p = FALSE)

Random Generation:

rskellam(n, lambda1, lambda2 = lambda1)

Saddlepoint Approximations:

dskellam.sp(x, lambda1, lambda2 = lambda1, log = FALSE)
pskellam.sp(q, lambda1, lambda2 = lambda1, lower.tail = TRUE, log.p = FALSE)

If Y_1 and Y_2 are Poisson variables with means \mu_1 and \mu_2 and correlation \rho, then X = Y_1 - Y_2 is Skellam with parameters:

\lambda_1 = \mu_1 - \rho \sqrt{\mu_1 \mu_2}

\lambda_2 = \mu_2 - \rho \sqrt{\mu_1 \mu_2}

The density is given by:

I(2 \sqrt{\lambda_1 \lambda_2}, |x|) (\lambda_1/\lambda_2)^{x/2} \exp(-\lambda_1-\lambda_2)

where I(y,\nu) is the modified Bessel function of the first kind.

Value

Invalid lambda values will return NaN with a warning.

Note

The VGAM package also provides Skellam functions. This implementation offers a broader working range, correct handling when one rate parameter is zero, enhanced argument checking, and improved accuracy for x < 0 (in R versions prior to 2.9). Use skellam::dskellam or VGAM::dskellam to specify which implementation to use.

References

Examples

# Compare with Poisson when one lambda = 0
dskellam(0:10, 5, 0)
dpois(0:10, 5)

# Both lambdas non-zero
dskellam(c(-1,1), c(12,10), c(10,12))
pskellam(c(-1,0), c(12,10), c(10,12))

# Quantile function
qskellam(c(0.05, 0.95), 3, 4)

# Random generation
rskellam(10, 8.5, 10.25)


[Package skellam version 0.2.4 Index]