From bolker at ufl.edu  Fri Jul  4 04:36:09 2008
From: bolker at ufl.edu (Ben Bolker)
Date: Thu, 03 Jul 2008 22:36:09 -0400
Subject: [Rd] update on dnbinom with large "size"
Message-ID: <486D8C99.2050006@ufl.edu>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


~  turns out I don't need to look at the C code.

~  if one uses the mu/size parameterization of the
negative binomial, R computes size/(size+mu) to
switch parameterizations.  If size>>mu this
gets rounded to 1 ... should be easy enough
to test and return NA under these circumstances?

function (x, size, prob, mu, log = FALSE)
{
~    if (!missing(mu)) {
~        if (!missing(prob))
~            stop("'prob' and 'mu' both specified")
~        prob <- size/(size + mu)
~    }
~    .Internal(dnbinom(x, size, prob, log))
}

~  Ben Bolker


- --------------------------
~  Check it out:

curve(dnbinom(1,mu=0.5,size=x),log="x",from=1,to=1e18)
abline(h=dpois(1,lambda=0.5),col=2,lty=2)
text(1,dpois(1,lambda=0.5)+0.02,"Poisson",col=2,pos=4)

~  I will take a look in the C code when I get
a chance to see if I can offer
a patch, but in the meantime wanted to alert people to
this "feature" ...  (it looks like I will have to go
through dnbinom and dbinom_raw to see where the problem
is ...)

~   Ben Bolker

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIbYyRc5UpGjwzenMRAh57AJ49SUuWs1++D7sacUnFZud2MAROhACfThzD
OmM9WuuFZrk4kO1s9MafLlk=
=wzaH
-----END PGP SIGNATURE-----



[Rd] update on dnbinom with large "size"
Ben Bolker