# Confidence interval for expected proportions with Chi-Squared test

I have a number of observed counts in several categories, e.g. [50, 35, 15], that I compared to the expected counts, e.g. [33, 33, 33]. The Chi-Squared test tells me that the observed counts differ significantly from the expected counts (Chi-Squared=261.7, p<0.001).

I was wondering if there is a way of getting a confidence interval for the expectation. For example, one might consider 35 to be sufficiently close to the expectation in contrast to 55 and 15.

## migrated from stackoverflow.comOct 24 '18 at 11:17

This question came from our site for professional and enthusiast programmers.

• One option is to use prop.test(35,100, 0.33) and prop.test(55,100, 0.33) to compare the observed ratio with the expected ratio. You'll get the confidence intervals as ratios (percentages), which you can transform to counts. – AntoniosK Oct 24 '18 at 10:33
• This isn't really a Python question... You're looking for the algorithmic formula, rather than its implementation in Python. Maybe this question would be more appropriate in another Stack Exchange, since its more of a maths question than programming. – Namyts Oct 24 '18 at 10:34
• @Namyts: I was looking for an algorithmic and implementational solution, but realize that it may have been better placed at stats Stack Exchange. I'm not sure how aggressively downvoting questions is helpful to anyone though. – Joe Bathelt Oct 24 '18 at 10:43
• @JoeBathelt If its any consolation: I didn't downvote it. But there are other reasons why others have. For example: You didn't demonstrate any existing code or your own attempts, downvoting hides the question more quickly from other people looking or future searchers. On the bright side, I think you get a badge for this ;) Good luck in finding an answer elsewhere... – Namyts Oct 24 '18 at 10:52
• Given that you can interpret this as a proportion (count / total), you can estimate the CI using the binomial proportion confidence interval. – user2974951 Oct 24 '18 at 10:52