BNB: Beta Negative Binomial distribution for fitting a GAMLSS

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

Description

The BNB() function defines the beta negative binomial distribution, a three parameter distribution, for a gamlss.family object to be used in GAMLSS fitting using the function gamlss().

The functions dBNB, pBNB, qBNB and rBNB define the density, distribution function, quantile function and random generation for the beta negative binomial distribution, BNB().

The functions ZABNB() and ZIBNB() are the zero adjusted (hurdle) and zero inflated versions of the beta negative binomial distribution, respectively. That is four parameter distributions.

The functions dZABNB, dZIBNB, pZABNB,pZIBNB, qZABNB qZIBNB rZABNB and rZIBNB define the probability, cumulative, quantile and random generation functions for the zero adjusted and zero inflated beta negative binomial distributions, ZABNB(), ZIBNB(), respectively.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
BNB(mu.link = "log", sigma.link = "log", nu.link = "log")
dBNB(x, mu = 1, sigma = 1, nu = 1, log = FALSE)
pBNB(q, mu = 1, sigma = 1, nu = 1, lower.tail = TRUE, log.p = FALSE)
qBNB(p, mu = 1, sigma = 1, nu = 1, lower.tail = TRUE, log.p = FALSE, 
     max.value = 10000)
rBNB(n, mu = 1, sigma = 1, nu = 1, max.value = 10000)

ZABNB(mu.link = "log", sigma.link = "log", nu.link = "log",
      tau.link = "logit")
dZABNB(x, mu = 1, sigma = 1, nu = 1, tau = 0.1, log = FALSE)
pZABNB(q, mu = 1, sigma = 1, nu = 1, tau = 0.1, lower.tail = TRUE, 
       log.p = FALSE)
qZABNB(p, mu = 1, sigma = 1, nu = 1, tau = 0.1, lower.tail = TRUE, 
       log.p = FALSE, max.value = 10000)
rZABNB(n, mu = 1, sigma = 1, nu = 1, tau = 0.1, max.value = 10000)

ZIBNB(mu.link = "log", sigma.link = "log", nu.link = "log", 
      tau.link = "logit")
dZIBNB(x, mu = 1, sigma = 1, nu = 1, tau = 0.1, log = FALSE)
pZIBNB(q, mu = 1, sigma = 1, nu = 1, tau = 0.1, lower.tail = TRUE, 
       log.p = FALSE)
qZIBNB(p, mu = 1, sigma = 1, nu = 1, tau = 0.1, lower.tail = TRUE, 
       log.p = FALSE, max.value = 10000)
rZIBNB(n, mu = 1, sigma = 1, nu = 1, tau = 0.1, max.value = 10000)       

Arguments

mu.link

The link function for mu

sigma.link

The link function for sigma

nu.link

The link function for nu

tau.link

The link function for tau

x

vector of (non-negative integer)

mu

vector of positive means

sigma

vector of positive dispersion parameter

nu

vector of a positive parameter

tau

vector of probabilities

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]

p

vector of probabilities

q

vector of quantiles

n

number of random values to return

max.value

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

Details

The probability function of the BNB is

f(y|μ,σ, ν)=(Γ(y+1/ν)Β(y+(μν)/σ, 1/σ+1/ν +1 )/(Γ(y+1) Γ(1/ν) Β((μν)/σ, 1/σ+1) )

for y=0,1,2,3,..., μ>0, σ>0 and ν>0.

The distribution has mean μ.

Value

returns a gamlss.family object which can be used to fit a Poisson distribution in the gamlss() function.

Author(s)

Bob Rigby and Mikis Stasinopoulos d.stasinopoulos@londonmrt.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.

Rigby, R. A., Stasinopoulos, D. M., Heller, G. Z., and De Bastiani, F. (2019) Distributions for modeling location, scale, and shape: Using GAMLSS in R, Chapman and Hall/CRC. An older version can be found in http://www.gamlss.com/.

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.com/).

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.

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.

See Also

NBI, NBII

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
BNB()   # gives information about the default links for the beta negative binomial
# plotting the distribution
plot(function(y) dBNB(y, mu = 10, sigma = 0.5, nu=2), from=0, to=40, n=40+1, type="h")
# creating random variables and plot them 
tN <- table(Ni <- rBNB(1000, mu=5, sigma=0.5, nu=2))
r <- barplot(tN, col='lightblue')

ZABNB()
ZIBNB()
# plotting the distribution
plot(function(y) dZABNB(y, mu = 10, sigma = 0.5, nu=2, tau=.1),  
     from=0, to=40, n=40+1, type="h")
plot(function(y) dZIBNB(y, mu = 10, sigma = 0.5, nu=2, tau=.1),  
     from=0, to=40, n=40+1, type="h")
## Not run: 
library(gamlss)
data(species)
species <- transform(species, x=log(lake))
m6 <- gamlss(fish~ pb(x), sigma.fo=~1, data=species, family=BNB)

## End(Not run)

Example output

Loading required package: MASS

GAMLSS Family: BNB Beta Negative Binomial 
Link function for mu   : log 
Link function for sigma: log 
Link function for nu   : log 

GAMLSS Family: ZABNB zero adjusted BNB 
Link function for mu   : log 
Link function for sigma: log 
Link function for nu   : log 
Link function for tau  : logit 

GAMLSS Family: ZIBNB 
Link function for mu   : log 
Link function for sigma: log 
Link function for nu   : log 
Link function for tau  : logit 
Loading required package: splines
Loading required package: gamlss.data
Loading required package: nlme
Loading required package: parallel
 **********   GAMLSS Version 5.0-2  ********** 
For more on GAMLSS look at http://www.gamlss.org/
Type gamlssNews() to see new features/changes/bug fixes.

GAMLSS-RS iteration 1: Global Deviance = 632.2582 
GAMLSS-RS iteration 2: Global Deviance = 629.5883 
GAMLSS-RS iteration 3: Global Deviance = 626.2913 
GAMLSS-RS iteration 4: Global Deviance = 623.5843 
GAMLSS-RS iteration 5: Global Deviance = 622.0562 
GAMLSS-RS iteration 6: Global Deviance = 621.4817 
GAMLSS-RS iteration 7: Global Deviance = 621.3382 
GAMLSS-RS iteration 8: Global Deviance = 621.3034 
GAMLSS-RS iteration 9: Global Deviance = 621.2998 
GAMLSS-RS iteration 10: Global Deviance = 621.2993 

gamlss.dist documentation built on July 13, 2020, 5:08 p.m.