Skip to content
Prev 18798 / 20628 Next

question on nbinom1

I believe the R d/p/q/r functions corresponding to glmmTMB's 
implementation of *nbinom1 would look like this:


rnbinom1 <- function(n, mu, phi) {
     ## var = mu*(1+phi) = mu*(1+mu/k) -> k = mu/phi
     rnbinom(n, mu=mu, size=mu/phi)
}

dnbinom1 <- function(x, mu, phi, ...) {
     dnbinom(n, mu=mu, size=mu/phi, ...)
}

pnbinom1 <- function(q, mu, phi, ...) {
     pnbinom(q, mu=mu, size=mu/phi, ...)
}

qnbinom1 <- function(p, mu, phi, log=FALSE) {
     pnbinom(p, mu=mu, size=mu/phi, ...)
}


   (there would be an even more clever/inscrutable way to do this by 
transforming the body of the code, without repeating oneself so much, 
but it would probably be a bad idea)
On 10/12/20 6:34 AM, Mollie Brooks wrote: