DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....


Declaration: Chi2OfContTabYates (ContTab: TInt2DArray; var chisq, p: double): integer;

The function Chi2OfContTabYates calculates the chi-square value for a given 2x2 contingency table. The chi-square value is calculated using Yates's continuity correction (which should always be applied for 2x2 contingency tables). The parameter ContTab contains the contingency table (including the margin sums, see figure below), the variable parameters chisq and p return the chi-square value and the corresponding p value, respectively.

The function returns the following error codes:

 0 ... everything is OK
-1 ... the contingency table is not a 2x2 table
-2 ... one of the margin sums is zero