# Standard error calculation for difference in means

In the case of two independent samples, the formula for standard error of the difference in means is given by :

$$\sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}$$

Even though we are talking about a difference, why are the standard errors of each sample means are added together?

In your case, the statistic at hand is $$\Delta = \bar{X}_1 - \bar{X}_2$$, where $$\bar{X}_i$$ is the sample mean of an i.i.d. sample $$\mathcal{D}_i := \{X_{i, 1}, \ldots, X_{i, n_i}\} \sim(\mu_i, \sigma_i^2)$$, $$i = 1, 2$$. Under the additional assumption that $$\mathcal{D}_1$$ and $$\mathcal{D}_2$$ are independent, the standard deviation of $$\Delta$$ is clearly \begin{align*} \sigma := \sqrt{\operatorname{Var}(\Delta)} = \sqrt{\operatorname{Var}(\bar{X}_1) + \operatorname{Var}(\bar{X}_2)} = \sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}. \tag{1}\label{1} \end{align*} In the above calculation, you are seeing a "$$+$$" instead of "$$-$$" in the right hand side expression because $$\operatorname{Var}(X - Y) = \operatorname{Var}(X) + \operatorname{Var}(Y)$$ rather than "$$\operatorname{Var}(X - Y) = \operatorname{Var}(X) - \operatorname{Var}(Y)$$" (again, given that $$X$$ and $$Y$$ are independent). This is a probabilistic rule, and actually has nothing to do with statistical inference.
Now if you estimate $$\sigma_i^2$$ in $$\eqref{1}$$ by corresponding sample variance $$s_i^2$$, you then retrieved the standard error expression as you listed.