gamlss.dist (version 5.1-6)

NBI: Negative Binomial type I distribution for fitting a GAMLSS

Description

The NBI() function defines the Negative Binomial type I distribution, a two parameter distribution, for a gamlss.family object to be used in GAMLSS fitting using the function gamlss(). The functions dNBI, pNBI, qNBI and rNBI define the density, distribution function, quantile function and random generation for the Negative Binomial type I, NBI(), distribution.

Usage

NBI(mu.link = "log", sigma.link = "log")
dNBI(x, mu = 1, sigma = 1, log = FALSE)
pNBI(q, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)
qNBI(p, mu = 1, sigma = 1, lower.tail = TRUE, log.p = FALSE)
rNBI(n, mu = 1, sigma = 1)

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

x

vector of (non-negative integer) quantiles

mu

vector of positive means

sigma

vector of positive despersion parameter

p

vector of probabilities

q

vector of quantiles

n

number of random values to return

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]

Value

returns a gamlss.family object which can be used to fit a Negative Binomial type I distribution in the gamlss() function.

Warning

For values of \(\sigma<0.0001\) the d,p,q,r functions switch to the Poisson distribution

Details

Definition file for Negative Binomial type I distribution. $$P(Y=y|\mu, \sigma)= \frac{\Gamma(y+\frac{1}{\sigma})}{\Gamma(\frac{1}{\sigma}) \Gamma(y+1)}\hspace{1mm}\left( \frac{\sigma \mu}{1+\sigma \mu}\right)^y \hspace{1mm}\left( \frac{1}{1+\sigma \mu} \right)^{1/\sigma}$$ for \(y=0,1,2,\ldots,\infty\), \(\mu>0\) and \(\sigma>0\). This parameterization is equivalent to that used by Anscombe (1950) except he used \(\alpha=1/\sigma\) instead of \(\sigma\).

References

Anscombe, F. J. (1950) Sampling theory of the negative bimomial and logarithmic distributiona, Biometrika, 37, 358-382.

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. (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

gamlss.family, NBII, PIG, SI

Examples

Run this code
# NOT RUN {
NBI()   # gives information about the default links for the Negative Binomial type I distribution  
# plotting the distribution
plot(function(y) dNBI(y, mu = 10, sigma = 0.5 ), from=0, to=40, n=40+1, type="h")
# creating random variables and plot them 
tN <- table(Ni <- rNBI(1000, mu=5, sigma=0.5))
r <- barplot(tN, col='lightblue')
# library(gamlss)
# data(aids)
# h<-gamlss(y~cs(x,df=7)+qrt, family=NBI, data=aids) # fits the model 
# plot(h)
# pdf.plot(family=NBI, mu=10, sigma=0.5, min=0, max=40, step=1)
# }

Run the code above in your browser using DataCamp Workspace