rCompound: function rCompound

Description Usage Arguments Details Author(s) References Examples

Description

Function rCompound generates sample for the random variable X.

Usage

1
rCompound(n,parent,compound,compoundDist,params,...)

Arguments

n

number of observations

parent

name of the parent distribution. It can be any continuous distribution supported by R.

compound

name of the compound distribution. It can be any discrete distribution supported by this package.

compoundDist

list of available compounding distributions

params

Parameter or list of parameters of compounding distribution.

...

Parameters of continuous distribution could be provided as additional parameters.

Details

Parameters of the parent distribution must be provided in the same way as it is in built in R functions. See

http://127.0.0.1:23174/library/stats/html/Distributions.html

Author(s)

S. Nadarajah, B. V. Popovic, M. M. Ristic

References

Nadarajah S, Popovic B.V, Ristic M.M (2011) Compounding: An R Package for Computing Continuous Distributions Obtained by Compounding a Continuous and a Discrete Distribution (submitted)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
compoundDist <- c("geometric","poisson","negativebinomial","binomial",
"logarithmic","binomialbinomial","binomialpoisson",
"poissonbinomial","neymantypea","polyaaeppli",
"poissonpascal","pascalpoisson",
"logarithmicbinomial","logarithmicpoisson",
"poissonlindley",
"hyperpoisson","yule","waring","kattitypeh1",
"kattitypeh2","neymantypeb","neymantypec",
"hypergeometric","thomas")
n<-5
parentD<-"beta"
compoundD<-"hypergeometric"
params<-c(3,2,0.5)
rCompound(n,parentD,compoundD,compoundDist,params,shape1=2,shape2=0.3)

## The function is currently defined as
rCompound <- function(n, parent, compound,params, ...) {
    if (!exists(paste("p",parent,sep=""))) {
        return(paste("The parent distribution",parent,"doesn't exist"))
    }
    if (!is.element(compound,compoundDist)) {
        return(paste("The discrete distribution",compound,"doesn't exist"))
    }
    if (n<0)
     stop("Parameter n must be positive")
 if(!(abs(n-round(n))<.Machine$double.eps^0.5))
stop("Parameter n must be positive integer")

    zval <- runif(n)
    xval <- qCompound(zval,parent,compound,compoundDist,params,...)
    return(xval)
}

Example output

Loading required package: hypergeo
[1] 0.7930347 0.2197765 0.8185072 0.8330538 0.9660248

Compounding documentation built on May 2, 2019, 1:04 p.m.