# Replacing the parameter by the estimate in the variance formula

Let $$X_1,\ldots X_n\sim Bern(p)$$ be Bernoulli random variables and $$x_1\ldots x_n$$ their realizations. Suppose I want to find the variance of the estimator $$\overline X=\frac{X_1+\ldots X_n}{n}$$. If we don't know the parameter $$p$$, one way to do this is using the formula:

$$var(\bar X) = \frac{s^2}{n}$$, where $$s=\frac{\sum_{i=1}^n (x_i-\bar X)^2}{n}$$

However, if I understood well, in this slide of this class the professor uses Slutsky theorem to find this formula for the variance replacing the true parameter $$p$$ by the estimate $$\hat p$$:

$$var(\bar X)=\frac{\hat p(1-\hat p)}{n}$$

where $$\hat p = \frac{x_1+\ldots x_n}{n}$$.

I want to know which formula I should use in this case

\begin{align}\hat{\operatorname{var}(\bar X)}&=\frac{\sum (x_i-\bar x)^2}{n^2}=\frac{\sum x_i^2-2\sum x_i\bar x+\sum\bar x^2}{n^2}\\&=\frac{\sum x_i-2\hat p\sum x_i+n\hat p^2}{n^2}=\frac{n\hat p-2\hat p n \hat p+n\hat p^2}{n^2}\\&=\frac{\hat p-\hat p^2}{n}=\frac{\hat p (1-\hat p)}{n}\end{align}
Note that, the key ideas here are $$\hat p=\bar x$$ and $$x_i^2=x_i$$ for a Bernoulli random variable.