IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Represents a contingency table. More...
Public Member Functions | |
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 | |
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... | |
Private Attributes | |
string | name |
int | rows |
int | cols |
int[,] | counts |
int[] | rCounts |
int[] | cCounts |
int | tCounts |
Represents a contingency table.
Imagine a controlled experiment in which each data point consists of two category values. For example, a measurement of a driver's car and his nationality, or a person's sex and employment status. Such experiments are typically undertaken to determine what correlation exists between the categories.
|
inline |
Initializes a new contingency table.
rows | The number of rows, which must be positive. |
columns | The number of columns, which must be positive. |
|
inline |
Initializes a new contingency table with the given data set.
data | A (zero-based) matrix of contingency table entries. |
|
inline |
Increments the count in the specifed cel.
r | The (zero-based) row index. |
c | The (zero-based) column index. |
Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().
|
inlinevirtual |
Gets the total counts in the specified row.
r | The (zero-based) row index. |
Referenced by Test.BinaryContingencyTableTest.BinaryContingencyNullTest(), Test.BinaryContingencyTableTest.BinaryContingencyTest(), and Test.ContingencyTableTest.ContingencyTableOperations().
|
inlinevirtual |
Gets the total counts in the specified column.
c | The (zero-based) column index. |
Referenced by Test.BinaryContingencyTableTest.BinaryContingencyNullTest(), Test.BinaryContingencyTableTest.BinaryContingencyTest(), and Test.ContingencyTableTest.ContingencyTableOperations().
|
inlinevirtual |
Estimates the probability of the given cell in the underlying population.
r | The (zero-based) row index. |
c | The (zero-based) column index. |
Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().
|
inlinevirtual |
Estimates the marginal probility of the given row in the underlying population.
r | The (zero-based) row index. |
Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().
|
inlinevirtual |
Estimates the marginal probility of the given column in the underlying population.
c | The (zero-based) column index. |
Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().
|
inlinevirtual |
Estimates the probability of the given row, conditional on the given column.
r | The (zero-based) row index. |
c | The (zero-based) column index. |
Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().
|
inlinevirtual |
Estimates the probability of the given row, conditional on the given column.
r | The (zero-based) row index. |
c | The (zero-based) column index. |
Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().
|
inlinevirtual |
Performs a Pearson χ2 test for correlation in the table.
The Pearson Pearson χ2 test tests for correlation between the row and column values. If row and column values are uncorrelated, then the expected number of counts in a table entry is simply proportional to the totals for its row and column. If that number is large for all entries, then the central limit theorem suggests that the actual number of counts will be distributed normally with mean equal to the expected value and standard deviation equal to its square root. The χ2 statistic measures the departure of the actual table from this expectation in the uncorrelated case, and under this null hypothesis its distribution is known. Having calculated χ2, then, we can compute just how unlikely it was to obtain a value as large or larger than the one obtained.
In cases where either the actual or expected counts for some entries are small or zero, the assumptions of the Pearson χ2 test are violated and it should not be used. For 2 X 2 experiments, the BinaryContingencyTable.FisherExactTest is a viable alternative in these cases.
Referenced by Test.BinaryContingencyTableTest.BinaryContingencyTest().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
getset |
Gets or sets the name of the table.
|
getset |
Gets or sets the count in the specified cell.
r | The (zero-based) row index. |
c | The (zero-based) column index. |
|
get |
Gets the number of rows in the table.
Referenced by Test.ContingencyTableTest.ContingencyTableOperations().
|
get |
Gets the number of columns in the table.
Referenced by Test.ContingencyTableTest.ContingencyTableOperations().
|
get |
Gets the total counts in the table.
Referenced by Test.BinaryContingencyTableTest.BinaryContingencyNullTest(), Test.BinaryContingencyTableTest.BinaryContingencyTest(), Test.ContingencyTableTest.ContingencyTableOperations(), and Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().