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 |
.
Calculates the mass of observations from the discrete Laplace distribution.
ddisclap(x, p) pdisclap(x, p, lower.tail = TRUE) rdisclap(n, p)
ddisclap(x, p) pdisclap(x, p, lower.tail = TRUE) rdisclap(n, p)
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 |
The probability mass function for the discrete Laplace distribution with parameter is given by
for
.
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
.
'ddisclap' gives the probability mass, 'pdisclap' gives the distribution function, and 'rdisclap' generates random deviates.
Mikkel Meyer Andersen <[email protected]> and Poul Svante Eriksen
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)")
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 for models such as a generalized linear model.
DiscreteLaplace()
DiscreteLaplace()
This family can be used in for example fitting a generalized linear model using the glm
or glm.fit
function.
Mikkel Meyer Andersen <[email protected]> and Poul Svante Eriksen
glm
glm.fit
ddisclap
binomial
poisson
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
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 for models such as a generalized linear model.
DiscreteLaplace() ddisclap(x, p) pdisclap(x, p, lower.tail = TRUE) rdisclap(n, p)
Mikkel Meyer Andersen and Poul Svante Eriksen
Maintainer: Mikkel Meyer Andersen <[email protected]>
DiscreteLaplace
ddisclap
pdisclap
rdisclap