I am going to reverse-engineer this from experience with discrimination cases. I can definitely establish where the values of "one in 741," etc, came from. However, so much information was lost in translation that the rest of my reconstruction relies on having seen how people do statistics in courtroom settings. I can only guess at some of the details.
Wikipedia claims that the term was introduced by Pearson in On the theory of contingency and its relation to association and normal correlation. Pearson does indeed seem to have coined the term. He says (referring to two-way tables):
I term any measure of the total deviation of the classification from
independent probability a measure of its contingency....
The colors represent the level of the residual for that cell / combination of levels. The legend is presented at the plot's right. More specifically, blue means there are more observations in that cell than would be expected under the null model (independence). Red means there are fewer observations than would have been expected. You can read this as ...
Yes, they are the same. The Matthews correlation coefficient is just a particular application of the Pearson correlation coefficient to a confusion table.
A contingency table is just a summary of underlying data. You can convert it back from the counts shown in the contingency table to one row per observations.
Consider the example confusion matrix used ...
This is a good question, but a big one. I don't think I can provide a complete answer, but I will throw out some food for thought.
First, under your top bullet point, the correction you are referring to is known as Yates' correction for continuity. The problem is that we calculate a discrete inferential statistic:
There may be some confusion about term "Barnard"s test or "Boschloo"s test. Barnard's exact test is an unconditional test in the sense that it does not condition on both margins. Therefore, both the second and third bullets are Barnard's test. We should instead write:
Both margins fixed (Hypergeometric Dist'n)→Fisher's exact test
One margin fixed (Double ...
Different visuals will be better at highlighting different features, but Mosaic plots work well for a general view (checking to see if anything stands out). Maybe that's what you meant by dodged bar plot. Like most options, they're not symmetric in that they represent relative frequencies better in one dimension than the other. A nice feature is that the ...
Ultimately, it's apples and oranges.
Logistic regression is a way to model a nominal variable as a probabilistic outcome of one or more other variables. Fitting a logistic-regression model might be followed up with testing whether the model coefficients are significantly different from 0, computing confidence intervals for the coefficients, or examining how ...
greater (or less) refers to a one-sided test comparing a null hypothesis
that p1=p2 to the alternative p1>p2 (or p1<p2). In contrast, a two-sided
test compares the null hypotheses to the alternative that p1 is not equal to
For your table the proportion of dieters that are male is 1/4 = 0.25 (10 out
of 40) in your sample. On the other hand, the ...
In the $2\times 2$ case the distributional assumption is given by two independent binomial random variables $X_1 \sim Bin(n_1, \theta_1)$ and $X_2 \sim Bin(n_2, \theta_2)$. The null hypothesis is the equality $\theta_1=\theta_2$.
But Fisher's exact test is a conditional test: it relies on the conditional distribution of $X_1$ given $X_1+X_2$. This ...
I don't see a big difference in the results:
d = read.table(text="Group Black Red
A 296 14
B 292 16
C 301 7
D 289 23", header=T)
# Pearson's Chi-squared test
# data: d[, 2:3]
# X-squared = 8.893, df = 3, p-value = ...
The first test tells you that the odds ratio between A and B, ignoring C, is different from 1. Looking at the stratified analysis helps you decide whether it's all right to ignore C.
The CMH test tells you that the odds ratio between A and B, adjusting for C, is different from one. It returns a weighted average of the stratum-specific odds ratios, so if ...
Fisher's so-called "exact" test makes the same kind of subtle assumptions that $\chi^2$ tests make.
The two variables being assessed for association are truly polytomous all-or-nothing variables such as dead/alive US/Europe. If one or both of the variables is a simplification of an underlying continuum, categorical data analysis should not be undertaken at ...
The solution depends intimately on how the data were collected and summarized. This answer takes you through a process of thinking about the data, analyzing them, reflecting on the results, and improving the test until some insight is achieved. Along the way we develop and compare five variants of the $\chi^2$ test.
Fisher's test is not applicable because ...
There isn't going to be a one-size-fits-all solution here. If you have a very simple table (e.g., $2\times 2$), simply presenting the table is probably best. If you want an actual figure, mosaic plots (as @xan suggests) are probably a nice place to start. There are some other options that are analogous to mosaic plots, including sieve plots, association ...
Conover (1999:202) suggested that the expected values can be "as small as 0.5, as long as most are greater than 1.0, without endangering the validity of the test."
He also provides a "rule of thumb" from Cochran (1952) which suggested that if expected values are less than 1 or if more than 20% are less than 5, the test may perform poorly. However, Conover (...
You need McNemar's test (http://en.wikipedia.org/wiki/McNemar%27s_test , http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3346204/). Following is an example:
1300 pts and 1300 matched controls are studied. The smoking status is tabled as follows:
Cancer|No |1000|40 |
|Yes |200 |60 |
Each entry of the table ...
To complement @gung's and @xan's answers, here's an example of mosaic and association plots using vcd in R.
activity morning noon afternoon evening
feed 28 4 0 56
social 38 5 9 10
travel 6 6 14 13
To obtain the plots:
mosaic(tab, shade=T, legend=T)...
I agree that the "best" plot doesn't exist independent of dataset, readership and purpose. For two measured variables, scatter plots are arguably the design that leaves all others in its wake, except for specific purposes, but no such market leader is evident for categorical data.
My aim here is just to mention a simple method, often re-discovered or re-...
They are asymptotically the same. They are just different ways of getting at the same idea. More specifically, Pearson's chi-squared test is a score test, whereas the G-test is a likelihood ratio test. To get a better sense of those ideas, it may help you to read my answer here: Why do my p-values differ between logistic regression output, chi-squared ...
The paradox is that there exist 2x2x2 contingency tables (Agresti,
Categorical Data Analysis) where the marginal association has a
different direction from each conditional association [...] Am I missing a subtle transformation from the original Simpson/Yule examples of contingency tables into real values that justify the regression line visualization?
It is best to get the data into a normalized form where smoking and heart attack are separate, parallel columns and other columns provide the identifying (key) fields:
country year smoking heart
1 Congo 1988 1200 900
2 Congo 1984 1146 400
3 Congo 2010 675 550
4 Nigeria 1988 1100 950
5 Nigeria 1984 ...
You are correct to be suspicious and you are correct that problems arise from some of the low cell counts in this case. However, there is nothing wrong with Fisher's test itself. We just need to be careful in interpreting its results.
Let's review the data:
0 1 Total
Site 1 7 2 | 9
Site 2 95 9 | 104
Site 3 0 1 | 1
What you are asking for here is a post-hoc power analysis. (More specifically, "the probability of correctly rejecting the null hypothesis" is the power, and 1-power is beta, "the probability of a type-II error". You ask for both, but we only need one to know the other.) We take your existing dataset as the alternative hypothesis / model of the true data ...
To analyze a multi-way contingency table, you use log-linear models. In truth, log-linear models are a special case of the Poisson generalized linear model, so you could do that, but log-linear models are more user-friendly. In Python, you may need to use the Poisson GLM, as I gather log-linear models may not be implemented. I will demonstrate the log-...
You may create a contingency table using a software tool called pivot table :)
A contingency table is a crosstable with rows, columns and data related to each of the row/column combination. You may draw such a table on a piece of paper, you may use an OLAP cube as the source of data etc. As this site says, a contingency table is essentially a display format ...
The "focal" association between category $i$ of one nominal variable and category $j$ of the other one is expressed by the frequency residual in the cell $ij$, as we know. If the residual is 0 then it means the frequency is what is expected when the two nominal variables are not associated. The larger the residual the greater is the association due to the ...
They measure slightly different things and need not give the same answers.
Chi-square measures association. It treats neither variable as dependent or independent. It can handle mxn tables, where the only limit is sample size, and gives one statistic for the whole table which is relatively easy to interpret.
Logistic regression does treat one variable as ...
I've looked into it using [R], and I am a bit surprised to see no packaged formula readily accessible for a test that is ubiquitous in the medical sciences. So it takes some minimal tweaking. First off, the link in my comment to the OP is excellent, providing a makeshift formula; however, the following is an example using well-known formulas in [R]: