Contingency table addin  Old version
We apologize that the rest of web page is temporarily only in Slovak language.
MS Addin for contingency table analysis. Addin includes functions for calculation of following statistical tests:
 Pearson chisquare test
 Cramer’s V, Pearson contingency coefficient and coefficient Phi
 Fisher exact test
 CochranArmitage test for linear trend
 GoodmanKruskal gamma (associated pvalue and 95% confidence interval)
 Kendall’s taub (associated pvalue and 95% confidence interval)
 Kendall’s tauc (associated pvalue and 95% confidence interval)
 Liddell (exact McNemar) test
 MantelHaenszel test (pooled OR of several stratified 2x2 tables; pvalue)
 Tests for single, two independent, and paired proportions (calculation of difference and 95% confidence interval for difference between these proportions)
 Point and interval estimation of odds ratio (95% CI calculation using Woolf and Cornfield method) and risk ratio

Download:
Please note that Addin works for MS Excel version 2003 and newer only, and that Office for PC is required. Although this Addin is written in excel VBA, which is included in Excel 2011 for Mac, there are substantial number of differences between excel VBA on Windows and Mac that makes this Addin incopatible.
Version for MS office 2010: Contingency Table (v. 2010).xlam
Version for MS office 2007, 2003: Contingency Table (v. 2007, 2003).xla
Examle data set can be dowloaded here Data sets.xlsx.
Please let us know (peter.slezak5(at)gmail.com) in case the above links don't work or any other questions.
Instruction video:
 (slovak version): www.youtube.com/watch?v=aiFFYX6b6g
 (english version): comming soon
Calculation details:
is Pearson Chi2 test statistics, where r denotes rows and c columns; i is the number of classes of grouping in the first category (row classification); j is the number of classifications of the second category (column classification); O is an observed frequency and E is an estimated expected frequency.
Cramer’s V is
, where I and J are the numbers of rows and columns, and N is the total number of events.
Pearson's contingency coefficient is calculated as follows
.
Coefficient Phi is defined as
.
Fisher's exact test: The P values are computed by considering all possible tables that could yield the observed row and column totals. The resulting Pvalue is the sum of P values for all the possible tables with Pvalue lower, or equal to that of the observed table. The midP value for a onesided test is obtained by including in the tail only one half of the probability of the observed table.
CochranArmitage test for linear trend: The test was proposed by Cochran [1] and Armitage [2] for analysing linear trend in k´2 contingency tables, where k levels of the first category are ordered. This way, the chisquare test for the trend is more powerful than the Pearson Chi2 test.
, where k is the number of rows, N is the grand total, R is the first column total, x_{i} is the score for linear trend (the function automatically assigns the integer score from 1 to k), n_{i} is the row total and r_{i} is the frequency in the first column.
Assessment of risk: Confidence interval (95%) for the odds ratio (OR) is calculated using Woolf (logit) [3] method and the method by Cornfield [4], as described in [5] on pp. 116119, where it was among the approximate methods, described as a method of choice. The confidence interval for risk ratio (RR) is calculated using logarithmic transformation [6,7].
Ordinal association: When analysing r x c contingency table with both categories being ordered, more testing power can be gained using ordinal methods, such as GoodmanKruskal gamma, Kendall's taub and tauc. The gamma statistics = (PQ)/(P+Q), where P is the number of concordant and Q is the number of discordant pairs. The pvalues and standard errors (ASE_{0})are calculated according to Goodman and Kruskal [8,9].
, where f_{ij} is the frequency in the ith row and jth column; W is the grand total; .
Kendall’s taub is similar to gamma, except tau b involves a correction for ties taub = (PQ)/√(D_{r}D_{c}). Where
with r_{j} as the total frequency of row i; and . The Standard error for taub is calculated according:
Kendall's tauc, similarly as taub, involves correction for ties, but it is more suitable for rectangular tables.
. Standard error for tauc is calculated as follows , where q is defined as min (number of rows, number of columns). Test statistic Z = τ_{c}/ASE_{0} follows a standard normal distribution.
Liddell's test. McNemar test is traditionally used when analysing paired proportions. However, the McNemar is an approximate test only, therefore we should use its exact alternative, according to Liddell [10].
MantelHaenszel test. This method due to Mantel and Haenszel [11] and extended by Mantel [12] is used for estimation of the common (pooled) odds ratio and for testing whether the overall degree of association in stratified 2x2 tables is significant. Pooled OR is defined as
, If any cell count in the table is equal to zero, then a continuity correction (that means adding of the value of 0.5) is applied to each cell of this table. The confidence interval for the pooled OR is calculated using the variance formula for logarithm of OR [13], future information see also [5] pp. 250254. The test statistic is used to test hypothesis that pooled OR is different from one. The statistic has a Chisquare distribution with one degree of freedom.
Proportions: The confidence interval for a single proportion is calculated according to the Wilson score method [14,15]. The confidence interval for the difference between two independent proportions is computed by the method combining the Wilson score intervals, which was introduced in [16]. The confidence interval for two paired proportions is computed using Newcombe’s modification of the Wilson's scorebased method [14,17].
References:
 W.G. Cochran, Some methods for strengthening the common chisquared tests, Biometrics 10 (1954) 417–451.
 P. Armitage, Tests for Linear Trends in Proportions and Frequencies, Biometrics 11 (1955) 375–386.
 B. Woolf, On estimating the relation between blood group and disease, Ann. hum. Genetics. 19 (1954) 251253
 J. Cornfield, A statistical problem arising from retrospective studies. Proceedings of the 3rd Berkeley Symposium. Berkeley: University of California Press 4 (1956) 135148.
 J.L. Fleiss, B. Levin, M.C. Paik, Statistical Methods for Rates and Proportions 3^{rd} ed. Wiley (2003).
 D. Katz, J. Baptista, S.P. Azen, M.C. Pike, Obtaining confidence intervals for the risk ratio in cohort studies, Biometrics 34 (1978) 469474
 J.A. Morris, M.J. Gardner, Epidemiological studies. In Statistics with Confidence 2^{nd} ed. London, BMJ Publishing Group, (2000) 5772.
 L.A. Goodman, W.H. Kruskal, Measures of Association for Cross Classifications. II: Further Discussion and References, J. Am. Statist. Assoc. 54 (1959) 123–163.
 L.A. Goodman, W.H. Kruskal, Measures of association for cross classifications, III: Approximate Sampling Theory, J. Am. Statist. Assoc. 58 (1963) 310 –364.
 F.D.K. Liddell, Simplified exact analysis of casereferent studies: matched pairs; dichotomous exposure, J. Epidemiol. Commun. H., 37 (1983) 8284.
 N. Mantel, W. Haenszel, Statistical aspects of the analysis of data from retrospective studies of disease, J. Natl. Cancer Inst. 22 (1959) 719748.
 N. Mantel, Chisquare test with one degree of freedom: extension of the MantelHaenszel procedure, J. Am. Statist. Assoc. 58 (1963) 690700.
 J. Robins, N. Breslow, S. Greenland, Estimators of the MantelHaenszel variance consistent in both sparse data and large strata models, Biometrics 42 (1986) 311323.
 E.B. Wilson, Probable inference, the law of succession, and statistical inference, J. Am. Statist. Assoc. 22 (1927) 209212.
 R.G. Newcombe, Twosided Confidence Intervals for the Single Proportion: Comparison of Seven Methods, Statist. Med. 17 (1998a) 857872.
 R.G. Newcombe, Interval estimation for the difference between independent proportions, Statist. Med. 17 (1998b) 873890.
 R.G. Newcombe, Improved confidence intervals for the difference between binomial proportions based on paired data, Statist. Med. 17 (1998c) 26352650.
Kontakt
Biomedstatv prípade problémov/otázok nás neváhajte kontaktovať na:
peter.slezak5(at)gmail.com