KIBNB: K-inflated Beta Negative Binomial distributions for fitting a...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

The function KIBNB defines the K-inflated Beta Negative Binomial distribution, a four parameter distribution, for a gamlss.family object to be used in GAMLSS fitting using the function gamlss().The functions dKIBNB, pKIBNB, qKIBNB and rKIBNB define the density, distribution function, quantile function and random generation for the K-inflated Beta Negative Binomia, KIBNB(), distribution.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 KIBNB(mu.link = "log", sigma.link = "log", nu.link = "log",
            tau.link = "logit", kinf="K")

dKIBNB(x, mu = 1, sigma = 1, nu = 1, tau = 0.1, kinf=0, log = FALSE)

pKIBNB(q, mu = 1, sigma = 1, nu = 1, tau = 0.1, kinf=0, lower.tail = TRUE,
            log.p = FALSE)

qKIBNB(p, mu = 1, sigma = 1, nu = 1, tau = 0.1, kinf=0, lower.tail = TRUE,
            log.p = FALSE, max.value = 10000)

rKIBNB(n, mu = 1, sigma = 1, nu = 1, tau = 0.1, kinf=0, max.value = 10000)

Arguments

mu.link

Defines the mu.link, with "log" link as the default for the mu parameter

sigma.link

Defines the sigma.link, with "log" link as the default for the sigma parameter

nu.link

Defines the nu.link, with "log" link as the default for the nu parameter

tau.link

Defines the tau.link, with "logit" link as the default for the tau parameter

x

vector of (non-negative integer) quantiles

mu

vector of positive means

sigma

vector of positive despersion parameter

nu

vector of nu

tau

vector of inflated point probability

p

vector of probabilities

q

vector of quantiles

n

number of random values to return

kinf

defines inflated point in generating K-inflated distribution

log,log.p

logical; if TRUE, probabilities p are given as log(p)

lower.tail

logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

max.value

a constant, set to the default value of 10000 for how far the algorithm should look for q

Details

The definition for the K-inflated Beta Negative Binomial distribution.

Value

The functions KIBNB return a gamlss.family object which can be used to fit K-inflated Beta Negative Binomial distribution in the gamlss() function.

Author(s)

Saeed Mohammadpour <s.mohammadpour1111@gamlil.com>, Mikis Stasinopoulos <d.stasinopoulos@londonmet.ac.uk>

References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion),Appl. Statist.,54, part 3, pp 507-554.

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use the GAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (see also http://www.gamlss.org/).

Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R.Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, http://www.jstatsoft.org/v23/i07.

Rigby, R. A. and Stasinopoulos D. M. (2010) The gamlss.family distributions, (distributed with this package or seehttp://www.gamlss.org/)

Stasinopoulos D. M., Rigby R.A., Heller G., Voudouris V., and De Bastiani F., (2017)Flexible Regression and Smoothing: Using GAMLSS in R, Chapman and Hall/CRC.

Stasinopoulos D. M., Rigby R.A., Heller G., Voudouris V., and De Bastiani F., (2017)Flexible Regression and Smoothing: Using GAMLSS in R, Chapman and Hall/CRC.

Najafabadi, A. T. P. and MohammadPour, S. (2017). A k-Inflated Negative Binomial Mixture Regression Model: Application to Rate-Making Systems. Asia-Pacific Journal of Risk and Insurance, 12.

See Also

gamlss.family, KIBNB

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#-------------------------------------------------------------------------------

KIBNB() # gives information about the default links for the  Beta Negative Binomial distribution
#-------------------------------------------------------------------------------

# generate zero inflated Beta Negative Binomial distribution
gen.Kinf(family=BNB, kinf=0)

# generate random sample from zero inflated Beta Negative Binomial distribution
x<-rinf0BNB(1000,mu=1, sigma=.5, nu=.2, tau=.2)

# fit the zero inflated Beta Negative Binomial distribution using gamlss
data<-data.frame(x=x)
## Not run: 
gamlss(x~1, family=inf0BNB, data=data)
histDist(x, family=inf0BNB)
## End(Not run)
#-------------------------------------------------------------------------------

# generated one inflated Beta Negative Binomial distribution
gen.Kinf(family=BNB, kinf=1)

# generate random sample from one inflated Beta Negative Binomial distribution
x<-rinf1BNB(1000,mu=1, sigma=.5, nu=.2, tau=.2)

# fit the one inflated Beta Negative Binomial distribution using gamlss
data<-data.frame(x=x)
## Not run: 
gamlss(x~1, family=inf1BNB, data=data)
histDist(x, family=inf1BNB)
## End(Not run)
#-------------------------------------------------------------------------------

mu=4; sigma=.5; nu=.2; tau=.2;
par(mgp=c(2,1,0),mar=c(4,4,4,1)+0.1)

#plot the pdf using plot
plot(function(x) dinf1BNB(x, mu=mu, sigma=sigma, nu=nu, tau=tau), from=0, to=20,
n=20+1, type="h",xlab="x",ylab="f(x)",cex.lab=1.5)
#-------------------------------------------------------------------------------

#plot the cdf using plot
cdf <- stepfun(0:19, c(0,pinf1BNB(0:19, mu=mu, sigma=sigma, nu=nu, tau=tau)), f = 0)
plot(cdf, xlab="x", ylab="F(x)", verticals=FALSE, cex.points=.8, pch=16, main="",cex.lab=1.5)
#-------------------------------------------------------------------------------

#plot the qdf using plot
invcdf <- stepfun(seq(0.01,.99,length=19), qinf1BNB(seq(0.1,.99,length=20),mu, sigma), f = 0)
plot(invcdf, ylab=expression(x[p]==F^{-1}(p)), do.points=FALSE,verticals=TRUE,
     cex.points=.8, pch=16, main="",cex.lab=1.5, xlab="p")
#-------------------------------------------------------------------------------

# generate random sample
Ni <- rinf1BNB(1000, mu=mu, sigma=sigma, nu=nu, tau=tau)
 hist(Ni,breaks=seq(min(Ni)-0.5,max(Ni)+0.5,by=1),col="lightgray", main="",cex.lab=2)
barplot(table(Ni))
#-------------------------------------------------------------------------------

gamlss.countKinf documentation built on May 2, 2019, 2:10 p.m.