Chi-square tests

version (2.48 KB) by Steinar Thorvaldsen
Three Chi-square tests of homogeneity and independence (Read-Cressie, Pearson or Log Likelihood)


Updated 23 Dec 2010

View License

Chi-square tests of homogeneity and independence.
Computes the P-value for I x J - table row/col independence.
Ref.: DeltaProt toolbox at

X: data matrix (I x J -table) of the observed frequency cells.
method: 'RC': Read-Cressie power divergence statistics (default), lambda= 2/3
'Pe': Standard Pearson chi2-distance, lambda= 1
'LL': Log Likelihood ratio distance, lambda= 0


Use: P = chi2Tests(Observed,'RC')

The P-value is computed through approximation with chi-2 distribution
under the null hypothesis for all methods.
The 'RC'-method is sligtly better than the 'Pe'-method in small tables with unbalanced column margins

Please, use the following reference:
Thorvaldsen, S. , Flå, T. and Willassen, N.P. (2010) DeltaProt: a software toolbox for comparative genomics. BMC Bioinformatics 2010, Vol 11:573.

Other reference:
Rudas, T. (1986): A Monte Carlo Comparision of Small Sample Behaviour
of The Pearson, the Likelihood Ratio and the Cressie-Read Statistics. J.Statist. Comput. Simul, vol 24, pp 107-120.
Read, TRC and Cressie, NAC (1988): Goodness of Fit Statistics for Discrete Multivariate Data. Springer Verlag.
Ewens, WJ and Grant, GR (2001): Statistical Methods in Bioinformatics. Springer Verlag.

Cite As

Steinar Thorvaldsen (2022). Chi-square tests (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!