org.statcato.statistics.inferential
Class ContingencyTable

java.lang.Object
  extended by org.statcato.statistics.inferential.ContingencyTable

public class ContingencyTable
extends java.lang.Object

A contingency table. Provides methods that perform computations relevant to a test of independence in a contingency table.

Since:
1.0
Version:
%I%, %G%
Author:
Margaret Yau

Constructor Summary
ContingencyTable(java.util.Vector<java.util.Vector<java.lang.Double>> table)
          Constructor.
 
Method Summary
 double criticalValue(double confidenceLevel)
          Returns the critical value corresponding to the given confidence level and degrees of freedom of the contingency table.
 int DOF()
          Returns the degrees of freedom of a contingency table.
 double pValue()
          Returns the p-Value corresponding to the test statistic in a chi-square distribution.
 double testStatistics()
          Returns the test statistic for a test of independence between the row and column variable in the contingency table.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContingencyTable

public ContingencyTable(java.util.Vector<java.util.Vector<java.lang.Double>> table)
Constructor. A vector of vector of Double representing the table of observed frequencies is provided. The row and column totals are calculated. The expected frequencies are also computed.

Parameters:
table - vector of vector of Double representing the table of observed frequencies
Method Detail

testStatistics

public double testStatistics()
Returns the test statistic for a test of independence between the row and column variable in the contingency table. chi^2 = Sum((O-E)^2 / E).

Returns:
chi^2 test statistics

DOF

public int DOF()
Returns the degrees of freedom of a contingency table.

Returns:
degrees of freedom

criticalValue

public double criticalValue(double confidenceLevel)
Returns the critical value corresponding to the given confidence level and degrees of freedom of the contingency table.

Returns:
critical value

pValue

public double pValue()
Returns the p-Value corresponding to the test statistic in a chi-square distribution.

Returns:
p-value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object