2

Say we have tossed a coin $n$ times and have counted $s$ times of heads (success). So our estimated success probability for this binomial model is $p=s/n$.

Now we are interested to compute the confidence interval for this obtained proportion $p$. This interval (using the normal approximation) is given by:

$$I=p\pm z \sqrt{\frac{p(1-p)}{n}} $$

Question is, how can I compute the prefactor $z$ that is multiplied by the standard deviation? It is sometimes referred to as, a quantile of a standard normal distribution. It would be greatly appreciated if someone could showcase how $z$ can be computed here.

user929304
  • 231
  • 2
  • 13
  • Have you tried https://en.wikipedia.org/wiki/Normal_distribution ? – Tim May 09 '16 at 11:50
  • Note though that this only works well if (a) p is fairly close to 0.5 (b) n is large. See https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval for more detail. – mdewey May 09 '16 at 12:34
  • If I answered your question, please click on "accept". Otherwise, don't hesitate to ask follow-up questions. – Antoni Parellada May 09 '16 at 13:06
  • @mdewey very important remark, I wasn't aware of this. What should one opt for instead in case of p being close to 0? – user929304 May 09 '16 at 16:03
  • I usually use the Wilson score test-based intervals which seem generally recommended. – mdewey May 09 '16 at 16:04
  • @mdewey you re right, i just found a nice post on this matter: http://stats.stackexchange.com/questions/82720/confidence-interval-around-binomial-estimate-of-0-or-1 – user929304 May 09 '16 at 16:09
  • @mdewey hi again, thought you may be interested in this new post http://stats.stackexchange.com/questions/211800/composing-confidence-intervals-together appreciate any feedback. – user929304 May 11 '16 at 06:43

1 Answers1

4

You don't calculate $z$ - it is a quantile in the standard normal distribution.

The confidence interval estimates the population parameter $\pi$ based on the sampling distribution and the central limit theorem (CLT) that allows a normal approximation. Hence, given a SE, and a proportion, the $95\%$ confidence interval will be calculated as:

$p\,\pm\,Z_{\alpha/2}\,\text{SE}$

Given that $Z_{\alpha/2}=Z_{0.975}=1.959964\sim1.96$, the CI will be:

$p\,\pm\,1.96\,\sqrt{\frac{p\,(1-p)}{n}}.$

Antoni Parellada
  • 23,430
  • 15
  • 100
  • 197
  • Thanks a lot. 2 questions if i may: i) so z is completely independent of the proportion and the number of trials $n$? ii) I unfortubately still don't see how you computed $Z_{0.975}$, can it only be obtained numerically or there s a way to estimate it practically on a piece of paper? – user929304 May 09 '16 at 16:01
  • No problem. The answer to your first question is, yes, completely independent, and used only as an asymptotic approximation. And for the second question, it is the inverse of the [erf function](https://en.wikipedia.org/wiki/Error_function), $\bf erf^{-1}(0.975).$ You know the Gaussian pdf (the bell curve), I'm sure... You integrate it to get the cumulative probability distribution (cdf). You want to find the quantile at which the probability accumulated is $97.5\%$. – Antoni Parellada May 09 '16 at 16:10
  • @user929304 sadly you need to estimate it numerically. Your favourite software may do this for you. If you use R you need the qnorm function, sorry I cannot tell you how other software does it, if at all. – mdewey May 09 '16 at 16:14
  • I was wondering, how do we decide the percentage for the confidence interval, $95\%, 90\%, \cdots$? Is it arbitrary? It s very confusing because i can always ask for high confidence intervals e.g. $99.99999\%$, but what would be the downside of that? – user929304 May 10 '16 at 10:38
  • This is almost a philosophical question, but in practical terms, it has to do with type I and type II errors. – Antoni Parellada May 10 '16 at 10:45