negbin {RMKdiscrete}R Documentation

Helper functions for the (unvariate) negative binomial distribution.

Description

Helper functions for the (unvariate) negative binomial distribution: change-of-parameter, wrapper function for density.

Usage

dnegbin(x,nu,p,mu,log=FALSE)
negbinMVP(nu, p, mu, sigma2)

Arguments

x

Numeric vector of quantiles.

nu

Numeric; equivalent to argument size in dnbinom(), etc.

p

Numeric; equivalent to argument prob in dnbinom(), etc.

mu

Numeric vector of mean parameters.

sigma2

"Sigma squared"–numeric vector of variance parameters.

log

Logical; should the natural log of the probability be returned? Defaults to FALSE.

Details

Function dnegbin() is a wrapper for dnbinom(). Two of the three arguments nu, p, and mu must be provided. Unlike dnbinom(), dnegbin() will accept mu and p(prob) with nu(size) missing. In that case, it calculates nu as mu * p/(1-p), and passes nu and p to dnbinom().

Function negbinMVP() accepts exactly two of its four arguments, and returns the corresponding values of the other two arguments. For example, if given values for nu and p, it will return the corresponding means (mu) and variances (sigma2) of a negative binomial distribution with the given values of nu and p. negbinMVP() does not strictly enforce the parameter space, but will throw a warning for bad input values.

Value

dnegbin() returns a numeric vector of probabilities. negbinMVP() returns a numeric matrix with two columns, named for the missing arguments in the function call.

Author(s)

Robert M. Kirkpatrick rkirkpatrick2@vcu.edu

See Also

dnbinom()

Examples

## These two lines do the same thing:
dnegbin(x=1,nu=2,p=0.5)
dnbinom(x=1,size=2,prob=0.5)

## What is the mean of this distribution?
negbinMVP(nu=2,p=0.5) #<--mu=2

## These two lines also do the same thing:
dnegbin(x=1,nu=2,mu=2)
dnbinom(x=1,size=2,mu=2)

## Parametrize with mu & p:
dnegbin(x=1,mu=2,p=0.5)
## Not run (will throw an error):
## dnbinom(x=1,prob=0.5,mu=2) 

[Package RMKdiscrete version 0.2 Index]