Last data update: 2014.03.03

R: The Noncentral Hypergeometric Distribution
NoncenHypergeomR Documentation

The Noncentral Hypergeometric Distribution

Description

Evaluates the density at a single point or all points, and generate random draws from the Noncentral Hypergeometric distribution.

Usage

dnoncenhypergeom(x=NA, n1, n2, m1, psi)
rnoncenhypergeom(n, n1, n2, m1, psi)

Arguments

x

The location to evaluate the density. If x is NA, then a matrix is returned with the density evaluated at all possible points.

n

The number of draws to make from the distribution.

n1

The size of group one.

n2

The size of group two.

m1

The observed number of positive outcomes (in both groups).

psi

Odds ratio.

Details

The Noncentral Hypergeometric is particularly useful for conditional inference for (2 x 2) tables. We use the parameterization and algorithms of Liao and Rosen (2001). The underlying R code is based on their published code. See their article for details of the parameterization.

Value

dnoncenhypergeom evaluates the density at point x, or a matrix with the first column containing the possible values of the random variable, and the second column containing the probabilities. rnoncenhypergeom returns a list of n random draws from the distribution.

Source

J. G. Liao and Ori Rosen. 2001. “Fast and Stable Algorithms for Computing and Sampling From the Noncentral Hypergeometric Distribution." The American Statistician. 55: 366-369.

Examples

  density <- dnoncenhypergeom(NA, 500, 500, 500, 6.0)
  draws <- rnoncenhypergeom(10, 500, 500, 500, 6.0)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MCMCpack)
Loading required package: coda
Loading required package: MASS
##
## Markov Chain Monte Carlo Package (MCMCpack)
## Copyright (C) 2003-2016 Andrew D. Martin, Kevin M. Quinn, and Jong Hee Park
##
## Support provided by the U.S. National Science Foundation
## (Grants SES-0350646 and SES-0350613)
##
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MCMCpack/noncenhypergeom.Rd_%03d_medium.png", width=480, height=480)
> ### Name: NoncenHypergeom
> ### Title: The Noncentral Hypergeometric Distribution
> ### Aliases: NoncenHypergeom rnoncenhypergeom dnoncenhypergeom
> ### Keywords: distribution
> 
> ### ** Examples
> 
>   density <- dnoncenhypergeom(NA, 500, 500, 500, 6.0)
>   draws <- rnoncenhypergeom(10, 500, 500, 500, 6.0)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>