negbin | R Documentation |
Helper functions for the (unvariate) negative binomial distribution: change-of-parameter, wrapper function for density.
dnegbin(x,nu,p,mu,log=FALSE) negbinMVP(nu, p, mu, sigma2)
x |
Numeric vector of quantiles. |
nu |
Numeric; equivalent to argument |
p |
Numeric; equivalent to argument |
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 |
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.
dnegbin()
returns a numeric vector of probabilities. negbinMVP()
returns a numeric matrix with two columns, named for the missing arguments in the function call.
Robert M. Kirkpatrick rkirkpatrick2@vcu.edu
dnbinom()
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.