Re: [Rd] dgamma error condition?

From: Ben Bolker <bolker_at_zoo.ufl.edu>
Date: Tue 08 Nov 2005 - 14:17:33 GMT

   thanks. would you like a patch?
(seems easy enough but I thought I'd offer) looks like library/stats/R/distn.R and
nmath/rgamma.c need fixing; looks like
qgamma may not check for scale<0 in C
code either ...

   Ben Bolker

Prof Brian Ripley wrote:
> On Fri, 4 Nov 2005, Ben Bolker wrote:
>
>>
>> There's an apparent inconsistency between the
>> behavior of d(pqr)gamma and other distribution
>> functions for "bad" parameter values. Specifically,
>> most distributions give NaN and a warning for bad
>> parameters (e.g. probabilities <0 or >1). In contrast,
>> d(pqr)gamma actually gives an error and stops when shape<0.
>> I don't see why it has to be this way -- the internal
>> C code is set up to detect shape<0 (or scale<0) and
>> return NaN and a warning, and none of the other
>> distribution functions in that bit of the code have
>> similar behavior.
>>
>> It would seem more consistent (and would be more
>> convenient for me -- the error-instead-of-warning
>> is making me have to jump through additional hoops)
>> if dgamma just returned NaN and a warning.
>>
>> Any thoughts?
>
>
> No one has come up with any, so let us remove the errors in R-devel.
>
> Note that rgamma is not protected at C level: try rgamma(10, -2), or
> (worse) rgamma(10, -20) after removing the stop() call.
>



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Nov 09 02:08:55 2005

This archive was generated by hypermail 2.1.8 : Tue 08 Nov 2005 - 16:21:18 GMT