Contingency Table¶
This summary produces a graphic representation of a 2x2 contingency table for two variables that have their values subdivided into two groups (nominally positive and negative). The summary includes a table of values showing the results of statistical tests for independence of the two groups, the risk ratio, odds ratios and related statistics, and total and conditional probabilities.
Either numeric or categorical variables may be used. For numeric variables, a threshold must be specified. All values either above or below this threshold (as specified on the dialog) will be in the ‘positive’ group, and all other values will be in the ‘negative’ group. For categorical variables, all values of the variable will be listed. Multiple values can be selected by left-clicking on them. All of the selected values will be in the ‘positive’ group and the un-selected values will be in the ‘negative’ group.
The contingency table dialog prompts for:
Two numeric or categorical variables from drop-down lists.
For each variable, how to subdivide the values into ‘positive’ and ‘negative’ subsets. For numeric variables, an upper or lower threshold must be specified. For categorical variables, the ‘positive’ group of values must be selected from a list box.
The dialog then displays a contingency table of the number of co-occurrences of positive and negative values for each variable, and a table of statistics. The contingency table is immediately updated if any changes are made to the user’s selections on this dialog or, if only selected data are being used, changes are made to the selected data.
The complete set of statistics that may be shown is listed below. Not all of these values will be shown if there are empty cells (zeroes) in the contingency table.
The Chi-square statistic.
The p value for the Chi-square statistic.
The degrees of freeedom for the Chi-square test.
The Fisher exact test statistic.
The p value for the Fisher exact test.
The Barnard exact test statistic.
The p value for the Barnard exact test.
The Boschloo exact test statistic.
The p value for the Boschloo exact test.
The risk ratio (Ranganathan et al. 2015).
The odds ratio (Bland 2000).
The log odds ratio: the natural log of the odds ratio.
The standard error (SE) of the log odds ratio.
The 95% confidence interval (CI) for the log odds ratio.
Yule’s (1900) measure of association (Q).
Yule’s (1912) coefficient of colligation (Y).
Yule’s (1912) phi coefficient–this is equivalent to the Pearson correlation coefficient for binary data.
The probability (frequency) of a positive value of the row variable.
The probability of a positive value of the row variable given that the column variable is positive.
The probability of a positive value of the row variable given that the column variable is negative.
The probability (frequency) of a positive value of the column variable.
The probability of a positive value of the column variable given that the row variable is positive.
The probability of a positive value of the column variable given that the row variable is negative.
The probability of positive values of both row and column variables.
The probability of a positive value of either the row variable or the column variable.
Tests of independence will not be carried out when there are fewer than 20 total observations.
The table of statistics can be exported to a CSV file or spreadsheet with the Ctrl-S keystroke.