dnbinom_new: Random numbers for the negative binomial distribution.

View source: R/dnbinom_new.R

dnbinom_newR Documentation

Random numbers for the negative binomial distribution.

Description

Density for the negative binomial distribution with parameters mu, sd, var, size or prob. See dnbinom.

Usage

dnbinom_new(
  x,
  size = NULL,
  prob = NULL,
  mu = NULL,
  sd = NULL,
  var = NULL,
  log = FALSE
)

Arguments

x

vector of (non-negative integer) quantiles.

size

target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer.

prob

probability of success in each trial. 0 < prob <= 1.

mu

alternative parametrization via mean.

sd

alternative parametrization via standard deviation.

var

alternative parametrization via variance.

log

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

Details

dnbinom_new returns density for the negative binomial distribution

Value

Random numbers for the negative binomial distribution

Author(s)

Marc Girondot marc.girondot@gmail.com

Examples

## Not run: 
library("HelpersMG")
set.seed(1)
x <- rnbinom_new(n=100, mu=2, sd=3)
LnL <- NULL
df <- data.frame(mu=seq(from=0.1, to=8, by=0.1), "-LnL"=NA)
for (mu in df[, "mu"])
LnL <- c(LnL, -sum(dnbinom_new(x=x, mu=mu, sd=3, log=TRUE)))
df[, "-LnL"] <- LnL
ggplot(data = df, aes(x = .data[["mu"]], y = .data[["-LnL"]])) + geom_line()
# Examples of wrong parametrization
dnbinom_new(x=x, mu=c(1, 2), sd=3, log=TRUE)

## End(Not run)

HelpersMG documentation built on Sept. 12, 2024, 9:35 a.m.