Table

Tables

Fisher’s Exact Test

The story of Fisher’s exact test are as follows: “Ronald Fisher, a Bad Cup of Tea, and the Birth of Modern Statistics”, [https://www.sciencehistory.org/distillations/ronald-fisher-a-bad-cup-of-tea-and-the-birth-of-modern-statistics]

teat=matrix(c(4,0,0,4), ncol=2)
fisher.test(teat)
##
##  Fisher's Exact Test for Count Data
##
## data:  teat
## p-value = 0.02857
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  1.339059      Inf
## sample estimates:
## odds ratio
##        Inf
chisq.test(teat)
## Warning in chisq.test(teat): Chi-squared approximation may be incorrect

##
##  Pearson's Chi-squared test with Yates' continuity correction
##
## data:  teat
## X-squared = 4.5, df = 1, p-value = 0.03389

As we can see the result, Dr. Bristol’s ability is statistically significant with 5% critical level. Because of the number of observation, only 8 here makes a little gap between Fisher’s exact test and Chi square test but they will converge on the same value as the sample size increases.

Cochran-Armitage Trend Test

Sometimes we want to analyze the results as the intensity increases. However, the maximum intensity can bring some side-effect too. In this scenario, we would better use Chi-squared test as well to compare the results.

  low medium high
favorable 13 10 10
unfavarable 29 4 18
sum 42 14 28
prop.trend.test(c(13,10,10),c(42,14,28))
##
##  Chi-squared Test for Trend in Proportions
##
## data:  c(13, 10, 10) out of c(42, 14, 28) ,
##  using scores: 1 2 3
## X-squared = 0.38724, df = 1, p-value = 0.5338
x=matrix(c(13,29,10,4,10,18), ncol=3)
chisq.test(x)
##
##  Pearson's Chi-squared test
##
## data:  x
## X-squared = 7.4367, df = 2, p-value = 0.02427

The trend test result shows we cannot find the significant trend on the dataset but the Chi-squared result tells us that the intensity and the outcome have a significant correlation. One thing we need to note is that when you use the trend test, we use the ratio between one dependent variable and the sum.

McNemar Test

This test is used when binary values are matched. If Chi-squared test is corresponding to a t-test, McNemar is to a paired t-test.

x=matrix(c(5,15,5,7),ncol=2)
mcnemar.test(x)
##  McNemar's Chi-squared test with continuity correction
##  
##  data:  x
##  McNemar's chi-squared = 4.05, df = 1, p-value = 0.04417    
Written on February 21, 2020