dalapl: Density and random draws from the asymmetric Laplace...

Description Usage Arguments Details Value Author(s) Examples

View source: R/alapl.R

Description

dalapl evaluates the probability density function, palapl the cumulative probability function and ralapl generates random draws.

Usage

1
2
3
4
5
dalapl(x, th=0, scale=1, alpha=0, logscale=FALSE)

palapl(x, th=0, scale=1, alpha=0)

ralapl(n, th=0, scale=1, alpha=0)

Arguments

x

Vector of values at which to evaluate the pdf/cdf

n

Number of random draws

th

Location parameter (mode)

scale

Scale parameter (proportional to variance)

alpha

Asymmetry parameter, must be between -1 and 1

logscale

If TRUE the log-pdf is returned

Details

For x<=th the asymmetric Laplace pdf is

0.5*exp(-abs(th-x)/(sqrt(scale)*(1+alpha)))/sqrt(scale)

and for x>th it is

0.5*exp(-abs(th-x)/(sqrt(scale)*(1-alpha)))/sqrt(scale)

Value

dalapl returns the density function, palapl the cumulative probability, ralapl random draws.

Author(s)

David Rossell

Examples

1
2
3
4
5
library(mombf)
e <- ralapl(n=10^4, th=1, scale=2, alpha=0.5)
thseq <- seq(min(e),max(e),length=1000)
hist(e, main='', breaks=30, prob=TRUE)
lines(thseq, dalapl(thseq, th=1, scale=2, alpha=0.5), col=2)

mombf documentation built on Dec. 6, 2019, 3:01 a.m.