Contingency tables are used to analyze counts of subjects to determine if there is association between two factors. This calculator is for 2x2 contingency tables that separate each subject into one of four categories based on two factors, each with two possibilities. Simply label the rows and columns, then type in the counts for each cell to test the relationship between the two factors. Learn more about contingency tables (along with when to use each test) in the description below the calculator.
Contingency tables are used to analyze count data across two or more experimental factors by separating the subjects into the appropriate categories. An example is comparing subjects with and without some risk factor (such as smoking/non-smoking) and further categorizing by whether they have a disease (such as lung cancer).
Unlike regression analysis or ANOVA, both of the factors are categorical (rather than numeric variables). A 2x2 table means that subjects are separated based on two factors (or questions) with two levels in each factor (groups 1 or 2 for the first factor and outcome 1 or 2 for the second factor). Each subject falls into one of the two levels for each factor, which results in four possible categories in all.
The goal is to determine if the factors are associated, for example, a subject in group 1 may be more likely to be part of the outcome 2 category. Be careful with interpretation, though, as a relationship does not necessarily imply causation!
Enter your data into the contingency table calculator. Label your groups and outcomes, then enter the actual number of subjects in each category (whole numbers only, not percentages or decimals).
The typical statistical test for contingency tables evaluates if there is an association between the variables. We provide three ways to compute a P value from a contingency table:
Then select either a one-tailed or two-tailed test. Two-tailed is more common for contingency tables. You can read more about P values here.
If you want to enter observed and expected values for each category (or your analysis is not exactly four categories in a 2x2 contingency table) you need this chi-square calculator instead.
Sign up for more information on how to perform contingency tests and other common statistical analyses.
Contingency tables and the tests listed above require the assumptions below to be met:
For more details, see our analysis checklist.
Suppose you recruit a fixed number of people with and without lung cancer. Then you interview each subject and record whether they are smokers or not. Notice these are both factors with exactly two possibilities.
This study would correspond to a contingency table like the one below, where you could count the number of subjects in each of the four categories. Testing the differences between the observed and expected counts can help you quantify the relationship between smoking and lung cancer.