BiasedUrnUnivariate {BiasedUrn}  R Documentation 
Statistical models of biased sampling in the form of noncentral hypergeometric distributions, including Wallenius' noncentral hypergeometric distribution and Fisher's noncentral hypergeometric distribution (also called extended hypergeometric distribution).
These are distributions that you can get when taking colored balls from an urn without replacement, with bias. The univariate distributions are used when there are two colors of balls. The multivariate distributions are used when there are more than two colors of balls.
Please see vignette("UrnTheory")
for a definition of these distributions and how
to decide which distribution to use in a specific case.
dWNCHypergeo(x, m1, m2, n, odds, precision=1E7)
dFNCHypergeo(x, m1, m2, n, odds, precision=1E7)
pWNCHypergeo(x, m1, m2, n, odds, precision=1E7, lower.tail=TRUE)
pFNCHypergeo(x, m1, m2, n, odds, precision=1E7, lower.tail=TRUE)
qWNCHypergeo(p, m1, m2, n, odds, precision=1E7, lower.tail=TRUE)
qFNCHypergeo(p, m1, m2, n, odds, precision=1E7, lower.tail=TRUE)
rWNCHypergeo(nran, m1, m2, n, odds, precision=1E7)
rFNCHypergeo(nran, m1, m2, n, odds, precision=1E7)
meanWNCHypergeo(m1, m2, n, odds, precision=1E7)
meanFNCHypergeo(m1, m2, n, odds, precision=1E7)
varWNCHypergeo(m1, m2, n, odds, precision=1E7)
varFNCHypergeo(m1, m2, n, odds, precision=1E7)
modeWNCHypergeo(m1, m2, n, odds, precision=1E7)
modeFNCHypergeo(m1, m2, n, odds, precision=0)
oddsWNCHypergeo(mu, m1, m2, n, precision=0.1)
oddsFNCHypergeo(mu, m1, m2, n, precision=0.1)
numWNCHypergeo(mu, n, N, odds, precision=0.1)
numFNCHypergeo(mu, n, N, odds, precision=0.1)
minHypergeo(m1, m2, n)
maxHypergeo(m1, m2, n)
x 
Number of red balls sampled. 
m1 
Initial number of red balls in the urn. 
m2 
Initial number of white balls in the urn. 
n 
Total number of balls sampled. 
N 
Total number of balls in urn before sampling. 
odds 
Probability ratio of red over white balls. 
p 
Cumulative probability. 
nran 
Number of random variates to generate. 
mu 
Mean x. 
precision 
Desired precision of calculation. 
lower.tail 
if TRUE (default), probabilities are

Allowed parameter values
All parameters must be nonnegative. n
cannot exceed N = m1 + m2
.
The code has been tested with odds in the range
10^{9} \ldots 10^9
and zero. The code may work with odds
outside this range, but errors or NAN can occur for extreme values of odds.
A ball with odds = 0 is equivalent to no ball.
mu
must be within the possible range of x
.
Calculation time
The calculation time depends on the specified precision.
dWNCHypergeo
and dFNCHypergeo
return the probability mass function for
Wallenius' and Fisher's noncentral hypergeometric distribution, respectively.
A single value is returned if x
is a scalar.
Multiple values are returned if x
is a vector.
pWNCHypergeo
and pFNCHypergeo
return the
cumulative probability function for
Wallenius' and Fisher's noncentral hypergeometric distribution, respectively.
A single value is returned if x
is a scalar.
Multiple values are returned if x
is a vector.
qWNCHypergeo
and qFNCHypergeo
return the quantile function for
Wallenius' and Fisher's noncentral hypergeometric distribution, respectively.
A single value is returned if p
is a scalar.
Multiple values are returned if p
is a vector.
rWNCHypergeo
and rFNCHypergeo
return
random variates with Wallenius' and Fisher's noncentral hypergeometric
distribution, respectively.
meanWNCHypergeo
and meanFNCHypergeo
calculate the mean
of Wallenius' and Fisher's noncentral hypergeometric
distribution, respectively. A simple and fast approximation is used when
precision \geq 0.1
.
varWNCHypergeo
and varFNCHypergeo
calculate the variance
of Wallenius' and Fisher's noncentral hypergeometric
distribution, respectively. A simple and fast approximation is used when
precision \geq 0.1
.
modeWNCHypergeo
and modeFNCHypergeo
calculate the mode
of Wallenius' and Fisher's noncentral hypergeometric
distribution, respectively.
oddsWNCHypergeo
and oddsFNCHypergeo
estimate the odds
of Wallenius' and Fisher's noncentral hypergeometric
distribution from a measured mean.
A single value is returned if mu
is a scalar.
Multiple values are returned if mu
is a vector.
A simple and fast approximation is used regardless of the specified precision.
Exact calculation is not supported.
See demo(OddsPrecision)
.
numWNCHypergeo
and numFNCHypergeo
estimate the
number of balls of each color in the urn before sampling from
an experimental mean and a known odds ratio for
Wallenius' and Fisher's noncentral hypergeometric distributions.
The returned numbers m1
and m2
are not integers.
A vector of m1
and m2
is returned if mu
is a scalar.
A matrix is returned if mu
is a vector.
A simple approximation is used regardless of the specified precision.
Exact calculation is not supported.
The precision of calculation is indicated by demo(OddsPrecision)
.
minHypergeo
and maxHypergeo
calculate the
minimum and maximum value of x
. The value is valid for
Wallenius' and Fisher's noncentral hypergeometric distribution
as well as for the (central) hypergeometric distribution.
Fog, A. 2008a. Calculation methods for Wallenius’ noncentral hypergeometric distribution. Communications in Statistics—Simulation and Computation 37, 2 doi:10.1080/03610910701790269
Fog, A. 2008b. Sampling methods for Wallenius’ and Fisher’s noncentral hypergeometric distributions. Communications in Statistics—Simulation and Computation 37, 2 doi:10.1080/03610910701790236
vignette("UrnTheory")
BiasedUrnMultivariate
.
BiasedUrn
.
fisher.test
# get probability
dWNCHypergeo(12, 25, 32, 20, 2.5)