debruine / faux

R functions for simulating factorial datasets

Home Page:https://debruine.github.io/faux/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: negative binomial variables

hughjonesd opened this issue · comments

These turn up in e.g. political science or any time you need count data but want to model the mean and variance separately.

I guess they could be supported by something as simple as

norm2negbin <- function (x, size = NULL, prob = 0.5, mu = mean(x)) {
    p <- stats::pnorm(x, mu, sd)
    stats::qnbinom(p, size, prob, mu)
}

where only one of prob and size should be specified.

Added to new dev version (leaving issue open until I write the reverse nbinom2norm function)

Thank you for this wonderful package! It's been critical for some power analyses I am doing.

I just came to also request the negative binomial distribution, especially included with the rmulti()function. I would also like to request it be able to be specified by the mean and size (dispersion parameter) parameterization.

@kayserb - The rmulti() function will work with literally any distribution that has r***, p***, and q*** functions, so already works with nbinom, but I have also just added it to the dev version 1.2.1.9002 (to be submitted to VRAN soon)