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.ContingencyTable Class Reference

Represents a contingency table. More...

+ Inheritance diagram for Meta.Numerics.Statistics.ContingencyTable:

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
 

Detailed Description

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.

See also
BinaryContingencyTable

Constructor & Destructor Documentation

Meta.Numerics.Statistics.ContingencyTable.ContingencyTable ( int  rows,
int  columns 
)
inline

Initializes a new contingency table.

Parameters
rowsThe number of rows, which must be positive.
columnsThe number of columns, which must be positive.
Meta.Numerics.Statistics.ContingencyTable.ContingencyTable ( int  data[,])
inline

Initializes a new contingency table with the given data set.

Parameters
dataA (zero-based) matrix of contingency table entries.

Member Function Documentation

void Meta.Numerics.Statistics.ContingencyTable.Increment ( int  r,
int  c 
)
inline

Increments the count in the specifed cel.

Parameters
rThe (zero-based) row index.
cThe (zero-based) column index.

Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().

virtual int Meta.Numerics.Statistics.ContingencyTable.RowTotal ( int  r)
inlinevirtual

Gets the total counts in the specified row.

Parameters
rThe (zero-based) row index.
Returns
The sum of all counts in the specified row.

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

virtual int Meta.Numerics.Statistics.ContingencyTable.ColumnTotal ( int  c)
inlinevirtual

Gets the total counts in the specified column.

Parameters
cThe (zero-based) column index.
Returns
The sum of all counts in the specified column.

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

virtual UncertainValue Meta.Numerics.Statistics.ContingencyTable.Probability ( int  r,
int  c 
)
inlinevirtual

Estimates the probability of the given cell in the underlying population.

Parameters
rThe (zero-based) row index.
cThe (zero-based) column index.
Returns
The probability for a random event to occur inthe given cell.

Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().

virtual UncertainValue Meta.Numerics.Statistics.ContingencyTable.ProbabilityOfRow ( int  r)
inlinevirtual

Estimates the marginal probility of the given row in the underlying population.

Parameters
rThe (zero-based) row index.
Returns
The probability for a random event to occur in the given row.

Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().

virtual UncertainValue Meta.Numerics.Statistics.ContingencyTable.ProbabilityOfColumn ( int  c)
inlinevirtual

Estimates the marginal probility of the given column in the underlying population.

Parameters
cThe (zero-based) column index.
Returns
The probability for a random envent to occur in the given column.

Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().

virtual UncertainValue Meta.Numerics.Statistics.ContingencyTable.ProbabilityOfRowConditionalOnColumn ( int  r,
int  c 
)
inlinevirtual

Estimates the probability of the given row, conditional on the given column.

Parameters
rThe (zero-based) row index.
cThe (zero-based) column index.
Returns
The probability for a random event to occur in the given row, if it appears in the given column.

Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().

virtual UncertainValue Meta.Numerics.Statistics.ContingencyTable.ProbabilityOfColumnConditionalOnRow ( int  c,
int  r 
)
inlinevirtual

Estimates the probability of the given row, conditional on the given column.

Parameters
rThe (zero-based) row index.
cThe (zero-based) column index.
Returns
The probability for a random event to occur in the given row, if it appears in the given column.

Referenced by Test.ContingencyTableTest.ContingencyTableProbabilitiesAndUncertainties().

virtual TestResult Meta.Numerics.Statistics.ContingencyTable.PearsonChiSquaredTest ( )
inlinevirtual

Performs a Pearson χ2 test for correlation in the table.

Returns
The result of the test. The test statistic is χ2 and its likelyhood under the null hypothesis is the (right) probability to obtain a value as large or larger.

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.

See also
ChiSquaredDistribution

Referenced by Test.BinaryContingencyTableTest.BinaryContingencyTest().

Member Data Documentation

string Meta.Numerics.Statistics.ContingencyTable.name
private
int Meta.Numerics.Statistics.ContingencyTable.rows
private
int Meta.Numerics.Statistics.ContingencyTable.cols
private
int [,] Meta.Numerics.Statistics.ContingencyTable.counts
private
int [] Meta.Numerics.Statistics.ContingencyTable.rCounts
private
int [] Meta.Numerics.Statistics.ContingencyTable.cCounts
private
int Meta.Numerics.Statistics.ContingencyTable.tCounts
private

Property Documentation

string Meta.Numerics.Statistics.ContingencyTable.Name
getset

Gets or sets the name of the table.

int Meta.Numerics.Statistics.ContingencyTable.this[int r, int c]
getset

Gets or sets the count in the specified cell.

Parameters
rThe (zero-based) row index.
cThe (zero-based) column index.
Returns
The count in the specified cell.
virtual int Meta.Numerics.Statistics.ContingencyTable.RowCount
get

Gets the number of rows in the table.

Referenced by Test.ContingencyTableTest.ContingencyTableOperations().

virtual int Meta.Numerics.Statistics.ContingencyTable.ColumnCount
get

Gets the number of columns in the table.

Referenced by Test.ContingencyTableTest.ContingencyTableOperations().


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