README.md

zil The Zero Inflated Laplace Distribution

The zil package extends R with the Zero Inflated Laplace Distribution and provides functions for calculation of the density, distribution and quantile functions including random number generation. The Zero Inflated Laplace is a flexible distribution used for e.g. meassurment error modeling where where a fraction (1/(1+p)) of errors can be zero, while also allowing for potential bias (parameter 'mu') and large spread in errors (parameter 'b').

Installation

Currently there isn't a release on CRAN, though there may one day be one. You can still download the zip or tar ball. Then decompress and run R CMD INSTALL on it, or use the devtools package to install the development version.

## Make sure your current packages are up to date
update.packages()
## devtools is required
library(devtools)
install_github("zil", "MarcoDVisser")

Examples

# using the density function and random numbers
x<-rzil(1000,mu=5)
hist(x,freq=FALSE)
lines(-5:15,dzil(-5:15,mu=5),lwd=3,col='green')

Here parameters include, the mean 'mu' sets the central tendency of the Laplace, with "b" defining the spread around 'mu'. The zero inflation parameter "p", defines the point mass density at 0. The density at zero relates to p as (1/(p+1)) while the probabilty density not equal to zero is given by 1-(1/(p+1)). The function "rzil" is based on the inverse cummulative function, and translates uniform random numbers to their zil equivalents.

Other formulations

A second set of functions are the centralized inflated laplace. Here the inflation is not on zero, but may be centred at mu. These can be used for modelling meassurement error centred arround mu. The parameter p then defines the fraction of instances that mu was meassured exactly as (1/(p+1)).

# using the density function and random numbers
x<-ril(1000,mu=5)
hist(x,freq=FALSE)
lines(-5:15,dil(-5:15,mu=5),lwd=3,col='green')


MarcoDVisser/zil documentation built on May 7, 2019, 2:50 p.m.