The Question is at the end of the reasoning.
1 : Representation of binomial confidence intervals:
We want to know if the proportion of reds in zone 1 is significantly different from the proportion of reds in zone 2
df <- matrix(c(58, 51, 8, 17), nrow = 2,
dimnames =
list(c("zone1", "zone2"),
c("Red", "Blue")))
df
prop.table(df, margin=1)
df2<- data.frame(prop=c(0.8787879, 0.7500000),
zone=c(1,2))
df2
plot(prop~zone, data=df2, ylim=c(0,1))
segments(x0 = 1, y0 = binom.test(58, 66)$conf.int[1],
x1 = 1, y1 = binom.test(58, 66)$conf.int[2], col = "red",
lty = 1, lwd = 3)
segments(x0 = 2, y0 = binom.test(51, 68)$conf.int[1],
x1 = 2, y1 = binom.test(51, 68)$conf.int[2], col = "red",
lty = 1, lwd = 3)
abline(h=binom.test(58, 66)$conf.int[1], lty=2)
abline(h=binom.test(51, 68)$conf.int[2], lty=2)
Clearly, the two group's confidence intervals are overlapping. They should be far from statistical significance if we perform a test.
2: Some stats:
calculation of statistical power to use the fisher test:
library('statmod')
(power.fisher.test(p1=0.88, p2=0.75, n1=66, n2=68, alpha=0.08, nsim=1000, alternative="two.sided"))
power of 0.53 considering the 13% of difference and sample size in each group
Now the fisher test:
fisher.test(df)
p <0.05
test for a difference. $\endgroup$