Bug 7393 - dhyper() does not allow non-integer values for input parameters mand n.
Summary: dhyper() does not allow non-integer values for input parameters mand n.
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: old
Hardware: ix86 (32-bit) Windows 32-bit
: P5 normal
Assignee: Jitterbug compatibility account
URL:
Depends on:
Blocks:
 
Reported: 2004-11-24 18:04 UTC by Jitterbug compatibility account
Modified: 2004-11-25 14:44 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jitterbug compatibility account 2004-11-24 18:04:05 UTC
From: Erik Jørgensen <Erik.Jorgensen@agrsci.dk>

dhyper() does not allow non-integer values for input parameters m and n.

this is in contrast to the other functions in the _hyper() "family",

  # OK
  dhyper(1,10,90,10)

  # NaN
  dhyper(1,10.5,90,10)

  # OK
  phyper(1,10,90,10)
  phyper(1,10.5,90,10)

  # OK
  qhyper(0.71,10,90,10)
  qhyper(0.71,10.5,90,10)

  # OK
  rhyper(1,10,90,10)
  rhyper(1,10.5,90,10)



# this "naive" version of dhyper() works

dhyperx<-function(x,m,n,k,log=FALSE){
       lp<-lchoose(m, x) + lchoose(n, k-x) - lchoose( m+n, k)
       if (log) {lp} else {exp(lp)}
       }

  # OK
  dhyperx(1,10,90,10)
  dhyperx(1,10.5,90,10)



Erik Jørgensen
Danish Institute of Agricultural Sciences



--please do not edit the information below--

Version:
  platform = i386-pc-mingw32
  arch = i386
  os = mingw32
  system = i386, mingw32
  status =
  major = 2
  minor = 0.1
  year = 2004
  month = 11
  day = 15
  language = R

Windows XP Professional (build 2600) Service Pack 1.0

Search Path:
  .GlobalEnv, package:methods, package:stats, package:graphics,
package:grDevices, package:utils, package:datasets, Autoloads, package:base

Comment 1 Jitterbug compatibility account 2004-11-24 21:10:10 UTC
From: Thomas Lumley <tlumley@u.washington.edu>
On Wed, 24 Nov 2004 Erik.Jorgensen@agrsci.dk wrote:

>
> dhyper() does not allow non-integer values for input parameters m and n.
>
> this is in contrast to the other functions in the _hyper() "family",

I would argue that the bug was in the other functions. If not, there is a 
bug in the documentation, which gives no way to tell what the result 
should mean for non-integer m, n, k.

 	-thomas


>  # OK
>  dhyper(1,10,90,10)
>
>  # NaN
>  dhyper(1,10.5,90,10)
>
>  # OK
>  phyper(1,10,90,10)
>  phyper(1,10.5,90,10)
>
>  # OK
>  qhyper(0.71,10,90,10)
>  qhyper(0.71,10.5,90,10)
>
>  # OK
>  rhyper(1,10,90,10)
>  rhyper(1,10.5,90,10)
>
>
>
> # this "naive" version of dhyper() works
>
> dhyperx<-function(x,m,n,k,log=FALSE){
>       lp<-lchoose(m, x) + lchoose(n, k-x) - lchoose( m+n, k)
>       if (log) {lp} else {exp(lp)}
>       }
>
>  # OK
>  dhyperx(1,10,90,10)
>  dhyperx(1,10.5,90,10)
>
>
>
> Erik Jørgensen
> Danish Institute of Agricultural Sciences
>
>
>
> --please do not edit the information below--
>
> Version:
>  platform = i386-pc-mingw32
>  arch = i386
>  os = mingw32
>  system = i386, mingw32
>  status =
>  major = 2
>  minor = 0.1
>  year = 2004
>  month = 11
>  day = 15
>  language = R
>
> Windows XP Professional (build 2600) Service Pack 1.0
>
> Search Path:
>  .GlobalEnv, package:methods, package:stats, package:graphics,
> package:grDevices, package:utils, package:datasets, Autoloads, package:base
>
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle
Comment 2 Jitterbug compatibility account 2004-11-24 23:32:15 UTC
From: Peter Dalgaard <p.dalgaard@biostat.ku.dk>
tlumley@u.washington.edu writes:

> >
> > dhyper() does not allow non-integer values for input parameters m and n.
> >
> > this is in contrast to the other functions in the _hyper() "family",
> 
> I would argue that the bug was in the other functions. If not, there is a=
> =20
> bug in the documentation, which gives no way to tell what the result=20
> should mean for non-integer m, n, k.


My initial reaction too (and surely it is not a bug that functions
behave inconsistently in regions where they are not documented to work
at all), but on the other hand, noninteger m,n do appear to give a
well-defined distribution, and perhaps there's a way of making sense
of it? I wouldn't think it corresponds to noncentral hypergeometric
distributions.


>  =09-thomas
(who is suddenly coming across in quoted-unreadable?)


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

Comment 3 Jitterbug compatibility account 2004-11-25 14:44:22 UTC
From: Martin Maechler <maechler@stat.math.ethz.ch>
>>>>> "PD" == Peter Dalgaard <p.dalgaard@biostat.ku.dk>
>>>>>     on 24 Nov 2004 18:32:15 +0100 writes:

    PD> tlumley@u.washington.edu writes:
    >> > > dhyper() does not allow non-integer values for input
    >> parameters m and n.
    >> >
    >> > this is in contrast to the other functions in the
    >> _hyper() "family",
    >> 
    >> I would argue that the bug was in the other functions. If
    >> not, there is a= =20 bug in the documentation, which
    >> gives no way to tell what the result=20 should mean for
    >> non-integer m, n, k.


    PD> My initial reaction too (and surely it is not a bug that
    PD> functions behave inconsistently in regions where they
    PD> are not documented to work at all), but on the other
    PD> hand, noninteger m,n do appear to give a well-defined
    PD> distribution, and perhaps there's a way of making sense
    PD> of it? I wouldn't think it corresponds to noncentral
    PD> hypergeometric distributions.

I'd tend to pretty much agree here.

Incidentally (slightly related, but prompted by something completely different),
just these hours I've been extending
     choose(r, k)
to work not just for integer but all positive 'n'.

Martin


Comment 4 Jitterbug compatibility account 2005-01-09 06:29:43 UTC
Audit (from Jitterbug):
Sun Jan  9 00:29:43 2005	thomas	moved from incoming to wishlist