sample.zi1: Generate random deviates from zero-inflated

sample.zi1R Documentation

Generate random deviates from zero-inflated

Description

Generate random deviates from zero-inflated Poisson, geometric, negative binomial, beta binomial, beta negative binomial, normal, log normal, half normal, and exponential models.

Usage

sample.zi1(N,phi,dist="poisson",lambda=NA,r=NA,p=NA,
alpha1=NA,alpha2=NA,n=NA,mean=NA,sigma=NA)

Arguments

N

The sample size. Should be a positive number. If it is not an integer, N will be automatically rounded up to the smallest integer that no less than N.

phi

The structural parameter φ, should be a positive value within (0,1).

dist

The corresponding standard distribution. Can be one of 'poisson', 'geometric','nb','bb', 'bnb','normal', 'lognormal', 'halfnormal','exponential', which corresponds to Poisson, geometric, negative binomial, beta binomial, beta negative binomial, normal, log normal, hal fnormal, and exponential distributions respectively.

lambda

A value for the parameter of Poisson distribution. Should be a positive number.

r

the number of success before which m failures are observed, where m is a random variable from negative binomial or beta negative binomial distribution. Must be a positive number. If it is not an integer, r will be automatically rounded up to the smallest integer that no less than r.

p

The probability of success, should be a positive value within (0,1).

alpha1

The first shape parameter of beta distribution. Should be a positive number.

alpha2

The second shape parameter of beta distribution. Should be a positive number.

n

The number of trials. Must be a positive number. If it is not an integer, n will be automatically rounded up to the smallest integer that no less than n.

mean

A value for parameter of the mean or expectation.

sigma

A value of parameter for standard deviation. Must be a positive real number.

Details

  • Setting dist=poisson and lambda, sample.zi1 simulates N random deviates from zero-inflated Poisson distribution, respectively, and so on forth.

  • Setting the dist=geometric and the argument p is for the use of zero-inflated geometric distributions.

  • ASetting the dist=nb and the arguments r and p are for the use of zero-inflated negative binomial distributions.

  • Setting the dist=bb and the arguments n, alpha1, and alpha2 are for zero-inflated beta binomial distributions.

  • Setting the dist=bnb and the arguments r, alpha1, and alpha2 are used in zero-inflated beta negative binomial distributions.

  • Setting the dist=normal and the arguments mean and sigma are used in zero-inflated normal distributions.

  • Setting the dist=lognormal and the arguments mean and sigma are used in zero-inflated log normal distributions.

  • Setting the dist=halfnormal and the argument sigma is used in zero-inflated half normal distributions.

  • Setting the dist=exponential and the argument lambda is used in zero-inflated exponential distributions.

Random deviates from standard Poisson, geometric, negative binomial, normal, log normal, and exponential distributions can be generated by basic R function rpois, rgeom, rnbinom, rnorm, rlnorm, and rexp in R package stats.

Functions rbbinom and rbnbinom, and rhnorm are available for standard beta binomial, beta negative binomial, and half normal distributions in R package extraDistr.

Value

A vector of length N containing non-negative integers from the zero-inflated version of distribution determined by dist.

References

  • H. Aldirawi, J. Yang, A. A. Metwally, Identifying Appropriate Probabilistic Models for Sparse Discrete Omics Data, accepted for publication in 2019 IEEE EMBS International Conference on Biomedical & Health Informatics (BHI) (2019).

  • T. Wolodzko, extraDistr: Additional Univariate and Multivariate Distributions, R package version 1.8.11 (2019), https://CRAN.R-project.org/package=extraDistr.

Examples

x1=sample.zi1(2000,phi=0.3,dist='poisson',lambda=10)         #zero-inflated Poisson
x2=sample.zi1(2000,phi=0.2,dist='geometric',p=0.2)           #zero-inflated geometric
x3=sample.zi1(2000,phi=0.3,dist='bb',n=10,alpha1=2,alpha2=4) #zero-inflated beta binomial
x4=sample.zi1(2000,phi=0.3,dist="normal",mean=10,sigma=2)    #zero-inflated normal
x5=sample.zi1(2000,phi=0.3,dist="exponential",lambda=20)     #zero-inflated exponential

AZIAD documentation built on Aug. 14, 2022, 9:05 a.m.

Related to sample.zi1 in AZIAD...