zi: Zero-Inflated distribution model (i.e., with an atom at zero)

Description Usage Arguments Value Examples

Description

Density, distribution function, quantile function and random generation for the zero-inflated (i.e., mixed) distribution model. This model is composed by two parts, 1) the discrete part, which regards an atom at zero, and 2) the continuous part, which regards a continuous distribution model (J-shaped and with left support >0).

Usage

1
2
3
4
5
6
7
dzi(x, Distr, p0, ...)

pzi(q, Distr, p0, ...)

qzi(p, Distr, p0, ...)

rzi(n, Distr, p0, ...)

Arguments

x, q

Vector of quantiles.

Distr

The name (as a function) of the continuous distribution model.

p0

Probability of zero values (i.e., zero-inflation).

...

Additional named arguments containing the continuous distribution parameters

p

Vector of probabilities.

n

Number of observations. If length(n) > 1, the length is taken to be the number required.

Value

dzi gives the density of the zero-inflated distribution model. pzi gives the cdf of the zero-inflated distribution model. qzi gives the quantile (ICDF) of the zero-inflated distribution model. rzi gives random variates from the zero-inflated distribution model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Plot the CDF of a Gamma distribution.
p=seq(0,1,0.01)
x=qzi(p, Distr = qgamma, p0=0.7, shape=0.5, scale=1)
plot(x, p)

## Generate 100000 random variables with p0=0.7 and
## Gamma distribution for the continoous part.
X=rzi1000, qgamma, p0=0.7, shape=0.5, scale=1)
hist(X)

## Generate 100000 random variables with p0=0.7 and
## Burr type XII distribution for the continuous part.
## The actuar package is required, since it contains
## the d,p,q,r functions of the Burr type XII distribution.
require(actuar)
X=rzi(1000, qburr, p0=0.7, shape1=5, shape2=1, scale=1)
hist(X)
plot(sort(X[X>0]), 1-ppoints(X[X>0], a=0), log='xy',
xlab = 'x', ylab = 'P[X>x]', main='Prob of exceedance plot')

itsoukal/anySim documentation built on May 7, 2020, 11:57 p.m.