This is a set of 116 observations taken from Statistical Methods in Biology, 2nd Edition N.J.T Bailey, Hodder and Stoughton, London, 1981 regarding the gender of the offspring of stallions.
Pearson's Chi-squared test
data: con
X-squared = 6.03, df = 5, p-value = 0.3033
Inoculation and Cholera
The 2x2 table is a special case because this only has a single degree of freedom. This results in inferences being biased and so a correction is applied to the calculation of the chi-squared statistic. This is called the Yates continuity correction.
For the epidemiological case which is a specific variant of the 2x2 table we also often want to calculate the risk ratio.
Once more the data is taken from Statistical Methods in Biology, 2nd Edition N.J.T Bailey, Hodder and Stoughton, London, 1981. This time the data is for Cholera inoculations.
For small cell count numbers in a 2x2 table it is also possible to calculate the Fisher’s Exact Test.
Once more the data is taken from Statistical Methods in Biology, 2nd Edition N.J.T Bailey, Hodder and Stoughton, London, 1981. This data is for drug treatments of a rare disease.
drug <-c(rep("A",5),rep("B",4))status <-c(rep("died",4),rep("recovered",1),rep("died",0),rep("recovered",4))rare_disease <-data.frame(drug,status)con2 <-xtabs(~drug+status, data=rare_disease)knitr::kable(addmargins(con2))
died
recovered
Sum
A
4
1
5
B
0
4
4
Sum
4
5
9
fisher.test(con2)
Fisher's Exact Test for Count Data
data: con2
p-value = 0.04762
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.7794899 Inf
sample estimates:
odds ratio
Inf
In this case the confidence interval and the odds ratio cannot be calculated because one of the values is 0 which gives a divide by 0 error.