0
$\begingroup$

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.

$\endgroup$

migrated from stackoverflow.com Oct 24 '18 at 11:17

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

  • 1
    $\begingroup$ 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. $\endgroup$ – AntoniosK Oct 24 '18 at 10:33
  • 3
    $\begingroup$ 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. $\endgroup$ – Namyts Oct 24 '18 at 10:34
  • 1
    $\begingroup$ @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. $\endgroup$ – Joe Bathelt Oct 24 '18 at 10:43
  • $\begingroup$ @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... $\endgroup$ – Namyts Oct 24 '18 at 10:52
  • $\begingroup$ Given that you can interpret this as a proportion (count / total), you can estimate the CI using the binomial proportion confidence interval. $\endgroup$ – user2974951 Oct 24 '18 at 10:52
2
$\begingroup$

One approach might be to construct confidence intervals for the observed counts. You will probably want to use confidence intervals for multinomial proportions, such as the Sison-Glaz approach. This is shown in my answer to this Cross Validated question. You can compare these to the expected, or to the other proportions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy