Comparing two proportions: Which standard error formula to use and when?

When comparing 2 proportions, I've seen 2 ways the standard error can be calculated.

The first I've seen is: $$SE = \sqrt{SE_1^2 + SE_2^2}$$

The second one is: $$SE = \sqrt{\hat{p}(1-\hat{p})(\frac{1}{n_1} + \frac{1}{n_2})}$$

Under what circumstances would I use the first one vs the second one?

What I'm trying to accomplish is calculate the z-score and confidence that $p_2$ is greater than $p_1$.

Edit, here are examples of sites that seem to talk about the same thing but use different SE formulas:

• Why don't you just do it the Bayesian way and model each probability as, e.g., a Beta distributed belief, and then calculation the probability that one belief is greater than the other? Feb 15, 2018 at 13:20
• Could you explain what are the variables in your equations? Feb 15, 2018 at 13:48
• My p_1 and p_2 are just proportions of people who did something. n_1 and n_2 are the numbers of observations. So if x_1 and x_2 are the number of people who did something out of the n_1 and n_2 observations, respectively, p-hat is (x_1 + x_2)/(n_1 + n_2) Feb 15, 2018 at 13:54
• Since in this context it would seem that "$SE_i^2$" must refer to $\hat p(1-\hat p)/n_i$, the step from the first expression to the second involves the simplest possible algebraic manipulation. Presumably, then, the $SE_i^2$ refer to some other formula: but what is it? Is this question really trying to get at the difference between separate and pooled estimates of $p$?
– whuber
Feb 15, 2018 at 16:28
• I think this may be going in the right direction. If $p_1$ = $p_2$ = $\hat p$ then yes it reduces easily. Is that what is implied? If I'm using $\hat p_1$ and $n_1$ for $SE_1$ and $\hat p_2$ and $n_2$ for $SE_2$, is it possible to prove the 2 expressions are similar? Feb 15, 2018 at 16:54

You would use $$SE = \sqrt{SE_1^2 + SE_2^2}$$ if you believe the variances are not similar and $$SE = \sqrt{\hat{p}(1-\hat{p})(\frac{1}{n_1} + \frac{1}{n_2})}$$ if you believe variances are similar.