s-news
[Top] [All Lists]

Re: Problem with qhyper() - more info

To: John Fennick <jhf2@bellsouth.net>
Subject: Re: Problem with qhyper() - more info
From: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Date: Thu, 21 Sep 2006 19:59:55 -0500
Cc: S-News List <s-news@lists.biostat.wustl.edu>
In-reply-to: <7.0.1.0.0.20060921195909.0186e9c8@bellsouth.net>
Organization: PDF Solutions, Inc.
References: <7.0.1.0.0.20060921195909.0186e9c8@bellsouth.net>
User-agent: Thunderbird 1.5.0.7 (Windows/20060909)


John Fennick said the following on 9/21/2006 6:59 PM:
Sorry, in prior note neglected to mention, using Splus 7.1 under Win XP

Hi Group,

The function qhyper(p,m,n,k) should take vectors for arguments m and n.

In the example below a vector in the call to create c11 works fine, but two vectors or even one, in the call to create c21 produces all -Inf. Even though any combination of single values from the two vectors produce
finite results.


ct <- 750 c1 <- 1:(ct-1)

                 c11 <- qhyper( 0.92, c1, (1000-c1), 1000*0.92 )
                    # vector for 3rd arg.
                    # Produces vector c11 of real integers (not shown)
c21 <- qhyper( 0.16, (ct-c1), (4000-p1), 4000*0.16)
                          # vectors for 3rd and 4th args.
                          # Produces vector c21 of all -Inf (not shown)
# Now delineate 2nd and 3rd args. of c21
                          p1 <- (ct-c1); q1 <- (4000-p1)
                 # And call them individually
i <- 74 # Or designation of any elements of p1, q1
                 c21.fixed <- qhyper( 0.16, p1[i], q1[i], 4000*0.16)
                          # Produces correct single result

What is wrong here?
Any suggestions?
john

John Fennick
jhf2@bellsouth.net
alt: j.fennick@ieee.org
Tel: 770 949-9132
7045 Fletcher Drive
Winston, GA 30187
USA


Hi, John,

Looks like a bug to me (at least in v6.2.1). If you look at the code for qhyper you see:

len <- max(length(m), length(n), length(k))
if(len == 1) {
  m <- round(m)
  n <- round(n)
  k <- round(k)
} else {
  len <- max(len, length(p))
  ## Huh??
  p <- rep(round(p), length.out = len) ## <-- Why round p??
  m <- rep(round(m), length.out = len)
  n <- rep(round(n), length.out = len)
  k <- rep(round(k), length.out = len)
}

You should send this to Insightful. Your workaround is to make your own copy of qhyper and change the offending line above to the following:

p <- rep(p, length.out = len)

HTH,

--sundar

<Prev in Thread] Current Thread [Next in Thread>