Chi-Squared Test

We are going to created a small dataset to perform some chi-squared test.

health = data.frame("no disease" = c(40, 30, 25), "diseased" = c(10, 20, 25), row.names = c("Drug A", "Drug B","Drug C"))
health
##        no.disease diseased
## Drug A         40       10
## Drug B         30       20
## Drug C         25       25
mosaicplot(health, color = T, main = "Comparison of Drugs effectiveness")

This dataset has 3 observations and 2 variables from which we can perform the test.

Chi-Squared with Simulation

chisq.test(health, simulate.p.value = T)
## 
##  Pearson's Chi-squared test with simulated p-value (based on 2000
##  replicates)
## 
## data:  health
## X-squared = 10.048, df = NA, p-value = 0.006497

Chi-Squared with Yates

chisq.test(health)
## 
##  Pearson's Chi-squared test
## 
## data:  health
## X-squared = 10.048, df = 2, p-value = 0.006579