IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Meta.Numerics.Statistics.BinaryContingencyTable Class Reference

Represents a 2 X 2 contingency table. More...

+ Inheritance diagram for Meta.Numerics.Statistics.BinaryContingencyTable:
+ Collaboration diagram for Meta.Numerics.Statistics.BinaryContingencyTable:

Public Member Functions

 BinaryContingencyTable ()
 Initializes a new binary contingency table. More...
 
 BinaryContingencyTable (int[,] data)
 Initializes a new binary contingency table with the given entries. More...
 
TestResult FisherExactTest ()
 Performs a Fisher exact test. More...
 
- Public Member Functions inherited from Meta.Numerics.Statistics.ContingencyTable
 ContingencyTable (int rows, int columns)
 Initializes a new contingency table. More...
 
 ContingencyTable (int[,] data)
 Initializes a new contingency table with the given data set. More...
 
void Increment (int r, int c)
 Increments the count in the specifed cel. More...
 
virtual int RowTotal (int r)
 Gets the total counts in the specified row. More...
 
virtual int ColumnTotal (int c)
 Gets the total counts in the specified column. More...
 
virtual UncertainValue Probability (int r, int c)
 Estimates the probability of the given cell in the underlying population. More...
 
virtual UncertainValue ProbabilityOfRow (int r)
 Estimates the marginal probility of the given row in the underlying population. More...
 
virtual UncertainValue ProbabilityOfColumn (int c)
 Estimates the marginal probility of the given column in the underlying population. More...
 
virtual UncertainValue ProbabilityOfRowConditionalOnColumn (int r, int c)
 Estimates the probability of the given row, conditional on the given column. More...
 
virtual UncertainValue ProbabilityOfColumnConditionalOnRow (int c, int r)
 Estimates the probability of the given row, conditional on the given column. More...
 
virtual TestResult PearsonChiSquaredTest ()
 Performs a Pearson χ2 test for correlation in the table. More...
 

Properties

UncertainValue OddsRatio [get]
 Computes the odds ratio of table. More...
 
UncertainValue LogOddsRatio [get]
 Computes the log of the odds ratio. More...
 
- Properties inherited from Meta.Numerics.Statistics.ContingencyTable
string Name [get, set]
 Gets or sets the name of the table. More...
 
int this[int r, int c] [get, set]
 Gets or sets the count in the specified cell. More...
 
virtual int RowCount [get]
 Gets the number of rows in the table. More...
 
virtual int ColumnCount [get]
 Gets the number of columns in the table. More...
 
virtual int Total [get]
 Gets the total counts in the table. More...
 

Detailed Description

Represents a 2 X 2 contingency table.

Binary contingency tables are the most common kind of contingency table. Any experiment with a treatment and a control group, and binary measured outcome, can be represented by a binary contingency table.

Constructor & Destructor Documentation

Meta.Numerics.Statistics.BinaryContingencyTable.BinaryContingencyTable ( )
inline

Initializes a new binary contingency table.

Meta.Numerics.Statistics.BinaryContingencyTable.BinaryContingencyTable ( int  data[,])
inline

Initializes a new binary contingency table with the given entries.

Parameters
dataA two-dimensional matrix of table entries.

Member Function Documentation

TestResult Meta.Numerics.Statistics.BinaryContingencyTable.FisherExactTest ( )
inline

Performs a Fisher exact test.

Returns
The results of the test. The test statistic is the summed probability of all tables exhibiting equal or stronger correlations, and its likelyhood under the null hypothesis is the (left) probability to obtain a smaller value. Note that, in this case, the test statistic itself is the likelyhood.

The Fisher exact test tests for correlations between row and column entries. It is a robust, non-parametric test, which, unlike the χ2 test (see ContingencyTable.PearsonChiSquaredTest), can safely be used for tables with small, even zero-valued, entries.

The Fisher test computes, under the null hypothesis of no correlation, the exact probability of all 2 X 2 tables with the same row and column totals as the given table. It then sums the probabilities of all tables that are as or less probable than the given table. In this way it determines the total probability of obtaining a 2 X 2 table which is at least as improbable as the given one.

The test is two-sided, i.e. when considering less probable tables it does not distinguish between tables exhibiting the same and the opposite correlation as the given one.

References Meta.Numerics.Interval.FromEndpoints(), and Meta.Numerics.Functions.AdvancedIntegerMath.LogFactorial().

Referenced by Test.BinaryContingencyTableTest.BinaryContingencyNullTest(), and Test.BinaryContingencyTableTest.BinaryContingencyTest().

Property Documentation

UncertainValue Meta.Numerics.Statistics.BinaryContingencyTable.OddsRatio
get

Computes the odds ratio of table.

For entries in the first row, the odds of landing in the first column are given by N[0,0] / N[0,1]. For entries in the second row, the odds of landing in the first column are given by N[1,0] / N[1,1]. The odds ratio is the ratio of these two odds. An odds ratio significantly different from 1 indicates a correlation between row and column values.

See also
LogOddsRatio

Referenced by Test.BinaryContingencyTableTest.BinaryContingencyNullTest(), and Test.BinaryContingencyTableTest.BinaryContingencyTest().

UncertainValue Meta.Numerics.Statistics.BinaryContingencyTable.LogOddsRatio
get

The documentation for this class was generated from the following file: