MichaelChirico / r-bugs

A ⚠️read-only⚠️mirror of https://bugs.r-project.org/
20 stars 0 forks source link

[BUGZILLA #10853] dhyper, phyper #3287

Closed MichaelChirico closed 4 years ago

MichaelChirico commented 4 years ago

From: Thomas Dye <tdye@<::CENSORED -- SEE ORIGINAL ON BUGZILLA::>> Aloha all,

I know too little about what I'm about to write and hope I'm not
wasting your time.

For a class I'm teaching in archaeological data analysis, I'm trying
to put together a routine that calculates the so-called Petersen
index and, especially, confidence intervals for the index. This was
introduced to archaeologists by N.R.J. Fieller and A. Turner in an
article in Journal of Archaeological Science (1982) called Number
Estimation in Vertebrate Samples. They say that "calculation of
precise confidence intervals for population sizes is, in principle at
least, straightforward. It involves calculation of cumulative
hypergeometric probabilities (i.e. the summation of probabilities
given by equation 3.1 of Seber, 1973)." The reference is to G.A.F.
Seber's book, The Estimation of Animal Abundance.

I went to equation 3.1 and wrote a small function to sum its
probabilities, modeled after phyper() and taking the arguments in the
same order (the names have changed to suit the archaeological
situation):

seber <- function(p,l,n,r)
{
y <- 0
for (x in 0:p)
y <- y + exp(lchoose(l,x) + lchoose(n-l,r-x) - lchoose(n,r))
y
}

When used in the larger routine, this yields results that very
closely approximate the results in Fieller and Turner's table 1.

I initially thought I could use the function phyper() for this
because, as I interpret the help files, this routine yields
cumulative hypergeometric probabilities. But I'm finding that it
gives different results than seber().

I apologize if I am in too far over my head, but I am wondering if
this is a bug in dhyper/phyper? Perhaps I have misunderstood what
phyper() actually does, or am calling it incorrectly? Or, were
Fieller and Turner in error?

All the best, Tom

Thomas Dye Dean Hall 201, Tuesday 1:00-1:55 pm


METADATA

MichaelChirico commented 4 years ago

NOTES: No indication of how he used phyper on what example.


METADATA

MichaelChirico commented 4 years ago

Audit (from Jitterbug): Sat Mar 1 07:22:27 2008 ripley moved from incoming to not-reproducible Thu Dec 18 09:15:46 2008 ripley changed notes


METADATA