Package 'disclap'

Title: Discrete Laplace Exponential Family
Description: The discrete Laplace exponential family for use in fitting generalized linear models.
Authors: Mikkel Meyer Andersen and Poul Svante Eriksen
Maintainer: Mikkel Meyer Andersen <[email protected]>
License: GPL-2
Version: 1.5.2
Built: 2024-10-31 05:04:34 UTC
Source: https://github.com/mikldk/disclap

Help Index


Probability mass function, distribution function, and random generation for the discrete Laplace distribution with parameter 0<=p<10 <= p < 1.

Description

Calculates the mass of observations from the discrete Laplace distribution.

Usage

ddisclap(x, p)
pdisclap(x, p, lower.tail = TRUE)
rdisclap(n, p)

Arguments

x

vector of observations

p

the parameter with 0 <= p < 1

lower.tail

logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x].

n

number of observations to generate

Details

The probability mass function for the discrete Laplace distribution with parameter 0<p<10 < p < 1 is given by P(X=x)=1p1+ppxP(X = x) = \frac{1-p}{1+p} p^{|x|} for xZx \in \mathbf{Z}.

If x is a vector, then p must have either length 1 or the same length as x. If p has length 1, then the value will be reused for all values in x.

Value

'ddisclap' gives the probability mass, 'pdisclap' gives the distribution function, and 'rdisclap' generates random deviates.

Author(s)

Mikkel Meyer Andersen <[email protected]> and Poul Svante Eriksen

See Also

DiscreteLaplace

Examples

p <- 0.3
xs <- (-4):4
probd <- ddisclap(xs, p)
data.frame(xs, probd)
plot(xs, probd, type = "l", xlab = "x", ylab = "P(X = x; p)")

Discrete Laplace exponential family

Description

Discrete Laplace exponential family for models such as a generalized linear model.

Usage

DiscreteLaplace()

Details

This family can be used in for example fitting a generalized linear model using the glm or glm.fit function.

Value

See binomial or poisson

Author(s)

Mikkel Meyer Andersen <[email protected]> and Poul Svante Eriksen

See Also

glm glm.fit ddisclap binomial poisson

Examples

xs <- abs(rdisclap(100, 0.1))
fit <- glm(xs ~ 1, family = DiscreteLaplace())
summary(fit)
theta <- as.numeric(coef(fit)[1])
mu <- DiscreteLaplace()$linkinv(theta)
p <- (sqrt(1 + mu^2) - 1) / mu
p

Discrete Laplace Family

Description

Discrete Laplace Family for models such as a generalized linear model.

Details

DiscreteLaplace() ddisclap(x, p) pdisclap(x, p, lower.tail = TRUE) rdisclap(n, p)

Author(s)

Mikkel Meyer Andersen and Poul Svante Eriksen

Maintainer: Mikkel Meyer Andersen <[email protected]>

See Also

DiscreteLaplace ddisclap pdisclap rdisclap