population proportion confidence interval When calculating a confidence interval for proportion, given a sample of the population, why is it "ok" that the standard deviation used is an estimate in itself? I mean, the actual standard deviation of $\hat{p} = \frac{x}{n}$ is $\sqrt{\frac{p(1-p)}{n}}$, how come it can be replaced by $\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}$?
Thanks!
 A: When we don't know a quantity, we estimate it using sample statistics. For example, when making confidence interval around the mean of a normal distribution, the standard deviation for the mean $\mu$ is $\sigma/\sqrt{n}$. Of course, we generally don't know this, so we replace it with $s/\sqrt{n}$, where
$$s = \sqrt{\dfrac{1}{n-1}\sum_{i=1}^{n}(x_i - \bar{x})^2 }\,. $$
The reason we can do this "replacement" is because as $n$ increases, $s$ converges to $\sigma$. That is, it becomes closer and closer to $\sigma$.
With the same logic, for the confidence interval of a proportion, the standard deviation of the sample proportion is $\sqrt{p(1-p)/n}$. The quantity that we don't know, we replace with its estimate, because as $n$ increases
$\hat{p}$ converges to $p$. In addition, for a function $g$, $g(\hat{p})$ converges to $g(p)$. Thus,
$$\sqrt{\dfrac{\hat{p}(1-\hat{p})}{n}} \text{ converges to } \sqrt{\dfrac{p(1-p)}{n}}\,.$$
So $\sqrt{\dfrac{\hat{p}(1-\hat{p})}{n}}$ is a good replacement for $ \sqrt{\dfrac{p(1-p)}{n}} \,.$
A: It could be viewed as an application of the plug-in principle: basically, you present the value you are interested in estimating as a functional of the underlying distribution $F(x)$, and then replace $F(x)$ with the empirical distribution function $F_n(x)$. 
Under some conditions on the functional, the resulting estimator converges to the true parameter value, and is asymptotically normal. 
A: The maximum likelihood estimate of $p$ is $\hat {p}$. The variance of the average is $p(1-p)/n$. Its MLE is $\hat {p} (1-\hat{p})/n$. Therefore the MLE of its standard error is $\sqrt{\hat {p} (1-\hat{p})/n}$. That is, the estimate with $n$ is maximum likelihood because functions of MLEs are (usually) themselves also MLEs.
