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:
I think the easiest way to get a numerical representation of the distribution from a fitted model would be using the simulate function. There?s an example of how to do that on pages 392-393 of this pdf (including Figs 6 and 7) https://journal.r-project.org/archive/2017/RJ-2017-066/RJ-2017-066.pdf <https://journal.r-project.org/archive/2017/RJ-2017-066/RJ-2017-066.pdf> cheers, Mollie
On 10Oct 2020, at 14:23, Don Cohen <don-lme4 at isis.cs3-inc.com> wrote: Mollie Brooks writes:
I don't have a copy of Hardin & Hilbe 2007 on hand, but I answered a few of your questions below.
Thank you. One more question: How can I compute the nbinom1 distribution? Is there a formula for the pdf or cdf ? An R function ?
[[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models