I have following values from an experiment:
A B
X 64 20
Y 62 11
I subject this to Chi-square test using following code:
from scipy.stats import chisquare
pval = chisquare([a,b], [c,d])[1]
print(pval)
Output is:
0.006421123271652286
This seems clearly significant (<0.05).
I now calculate odds ratio and its confidence intervals with above data using following formulae:
OR = (a*d) / (b*c)
se = math.sqrt((1/a)+(1/b)+(1/c)+(1/d))
lower = np.exp(math.log(OR) - 1.96*se)
upper = np.exp(math.log(OR) + 1.96*se)
print(OR, lower, upper)
Output is:
0.5677 0.2514 1.2819
( The confidence intervals agree with online calculator at https://select-statistics.co.uk/calculators/confidence-interval-calculator-odds-ratio/ )
So, confidence interval is very much overlapping 1, while I expected it to be on one side of 1 since P value was clearly significant.
I have following questions:
Where is the error and how can I correct it?
Would you call these data as statistically significant?
What test can I use so that P value and confidence intervals match?
Thanks for your help.