IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Represents a 2 X 2 contingency table. More...
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... | |
![]() | |
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... | |
![]() | |
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... | |
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.
|
inline |
Initializes a new binary contingency table.
|
inline |
Initializes a new binary contingency table with the given entries.
data | A two-dimensional matrix of table entries. |
|
inline |
Performs a Fisher exact test.
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().
|
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.
Referenced by Test.BinaryContingencyTableTest.BinaryContingencyNullTest(), and Test.BinaryContingencyTableTest.BinaryContingencyTest().
|
get |
Computes the log of the odds ratio.
Referenced by Test.BinaryContingencyTableTest.BinaryContingencyNullTest(), and Test.BinaryContingencyTableTest.BinaryContingencyTest().