I want to calculate the 95% confidence interval for a combination of binary data and continuous data.

Lets say I want to estimate the production of a certain item from all factories of a given country. I know the size of the population (1000) and take a sample of size 50 for example.

Out of the 50, say 10 produce item A. The 95% CI of that proportion would be 20% +- 8.3% i.e. 11.7% - 28.3%

If the values for item A are: 100, 80, 120, 200, 150, 90, 110, 190, 180, 120 The mean would be: 134 SEM: 13.7 and 95% CI would reach from 103 - 164

My Question is now: the best guess for the population production of item A is 20% * 134 so for all 1000 factories 134 * 200 (20% of 1000) but how about the 95% CI.

Do I take the minimum of both calculations i.e. 11.7% * 1000 * 103 and the maximum of both i.e.: 28.3% * 1000 * 164

It feels like I would include the maximum uncertainty and making the 95% CI to wide. But if I only use the mean proportion for both i.e. 20% * 1000 * 103 for min and 20% *1000 * 164 for max I feel like missing the second source of variance.

Doing 11.7% * 134 (mean production of A) * 1000 till 28.3% * 134 * 1000 doesnt seem to be right either.

Any thoughts?


One option would be to ignore the proportion part and just enter a value of 0 for the 40 that do not produce the item, then use the methods for the continuous values. If you are hesitant about whether your sample size is large enough for the Central Limit Theorem, or other assumptions then you could simulate from a known population and apply this to compute your confidence interval, repeat a bunch of times, and see how many of the confidence intervals contain the true value.

Another approach would be to simulate based on your assumptions and compute the interval based on that. If you are willing to assume that producing (yes/no) and value of the product (if produced) are independent, then you can generate a proportion based on the binomial and a mean based on the normal and estimates of the distribution of the mean, then multiply those, repeat a bunch of times and compute the confidence interval from the simulations. If you are not comfortable with the independence assumption then you would need to generate the values representing the relationship you think is there.

  • $\begingroup$ Thanks for the reply. I think that producing(yes/no) and amount of production can not be "independent", right? If no then I know it is 0, if yes it is at least 1. I was thinking about using the 0s as well. so that would increase the variance quite a bit, but I think you mean in the right way as in taking into acount the uncertainty of the proportion. Feels like calculating the amount of cigarets smoked a day but including non-smokers. But I think you are right for projecting to the population one should include the zeros. I feel comfortable with bootstrapping and simulations... $\endgroup$ – JollyRoger Apr 23 '14 at 23:31
  • $\begingroup$ ... it would be just a lot harder to explain to my boss ;) a nice clean equation for calculating the CI would have been better. $\endgroup$ – JollyRoger Apr 23 '14 at 23:35
  • 1
    $\begingroup$ @JollyRoger, you could look at a zero inflated model (possibly zero inflated poisson or zero inflated lognormal) for another way to fit your data. That may give you a "clean equation". Or you could ask your boss whether they prefer a simple wrong answer or a more complex, less wrong answer (see Thumb's second postulate, Meyer's law, and Grossman's misquote (zira.home.xs4all.nl/murphy.html)) $\endgroup$ – Greg Snow Apr 24 '14 at 13:49
  • 1
    $\begingroup$ @JollyRoger, the "less wrong" in my previous comment was in reference to Box's statement along the lines that "all models are wrong, some models are useful". You need to decide where the balance is between usefulness and simplicity for your boss. Sometimes the simple versions are fine (and more likely to be implemented), you just need to make sure that they are useful enough in addition to the simplicity. $\endgroup$ – Greg Snow Apr 24 '14 at 13:59
  • $\begingroup$ Yes I understood that remark (about the models) and totally agree. Always tricky when you try to do it the "right" way but its not your decission to make. I will try to create a population with known quantaties and then see how close bootstrapping comes with a subsample or the combination of the two different CIs. I will study up on the two models you recommended also! cheers $\endgroup$ – JollyRoger Apr 27 '14 at 11:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.