Skip to content
simstat.com Statistics by simulation

How to Calculate Standard Error: Mean, Proportion and Difference

How to calculate standard error for a sample mean: divide the sample standard deviation by the square root of the sample size, SE = s/√n. The standard error is the standard deviation of a statistic's sampling distribution, so it measures how precisely the sample estimates the population value. For a proportion it is √(p̂(1 − p̂)/n), for the difference between two independent means √(s₁²/n₁ + s₂²/n₂), and for a statistic with no simple formula, such as the median, it can be estimated as the standard deviation of bootstrap replicates.

Last updated · by the simstat.com editorial team · How we write

What the standard error measures

A sample mean is an estimate. Draw another sample of the same size and the mean comes out a little different; draw many and the means form the sampling distribution of the mean. The standard error (SE) is the standard deviation of that distribution: for an unbiased estimate such as the mean, the typical distance between the estimate and the population value it estimates. Altman and Bland (2005) describe it as “a measure of the precision of the sample mean”.

Every statistic has a standard error, not only the mean. Altman and Bland (2005) list proportions, regression coefficients and differences between two means or proportions, and say that “for all such estimates a standard error can be calculated to indicate the degree of uncertainty”. You never see the sampling distribution itself, because you have one sample, so in practice you estimate the standard error, either with a formula or by resampling.

To watch a sampling distribution form, run our sampling distribution simulator: the standard deviation of the simulated sample means is the standard error, and the tool shows it next to σ/√n. The sampling distribution guide explains the theory behind it.

Standard error of the mean

To find the standard error of the mean, divide the standard deviation by the square root of the sample size. Illowsky and Dean (2023, section 7.1) put it in words: “the standard deviation of the sampling distribution is the standard deviation of the original distribution divided by the square root of n”. The population standard deviation σ is rarely known, so you use the sample standard deviation s:

SExˉ=sn,s=∑(xi−xˉ)2n−1SE_{\bar{x}} = \frac{s}{\sqrt{n}}, \qquad s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n - 1}}

Here x̄ is the sample mean, n the number of observations and s the sample standard deviation, with n − 1 in its denominator. The n in √n is the number of values averaged, which Illowsky and Dean (2023, section 7.1) stress is “not the number of times the experiment is done”.

Worked example: standard error of the mean for mtcars fuel consumption

R’s mtcars data set gives the fuel consumption of 32 cars, “extracted from the 1974 Motor Trend US magazine” (R Core Team, 2024), in miles per US gallon.

Step 1: mean. The 32 values average x̄ = 20.09 mpg.

Step 2: standard deviation. With n − 1 = 31 in the denominator, s = 6.027 mpg.

Step 3: square root of n. √32 = 5.657.

Step 4: divide. SE = 6.027 ÷ 5.657 = 1.065 mpg.

In R, t.test(mtcars$mpg)$stderr returns the same standard error, and our confidence interval calculator shows it when you paste the 32 values.

Standard error of a proportion

For a sample proportion p̂ (the number of successes x divided by n), the standard error formula for a proportion is:

SEp^=p^ (1−p^)nSE_{\hat{p}} = \sqrt{\frac{\hat{p}\,(1 - \hat{p})}{n}}

Illowsky and Dean (2023, section 8.3) explain that the true standard deviation uses the unknown population proportion p, so the formula plugs in the sample proportion instead.

Worked example: standard error of a proportion (OpenStax smartphone survey)

In Illowsky and Dean’s (2023) Example 8.10, 421 of 500 randomly selected adults in a city said they own a smartphone.

Step 1: proportion. p̂ = 421 ÷ 500 = 0.842, so 1 − p̂ = 0.158.

Step 2: multiply and divide. p̂(1 − p̂)/n = 0.842 × 0.158 ÷ 500.

Step 3: square root. SE = 0.0163, or 1.6 percentage points.

The formula needs enough successes and failures. Illowsky and Dean (2023, section 8.3) use the resulting interval only when the number of successes np̂ and the number of failures n(1 − p̂) are both greater than five (many texts, and our calculator, use 10); here they are 421 and 79.

Standard error of a difference in means

To compare two independent groups, you need the standard error of x̄₁ − x̄₂. Each mean has its own error, and the variances add:

SExˉ1−xˉ2=s12n1+s22n2SE_{\bar{x}_1 - \bar{x}_2} = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}

This unpooled standard error is the one Illowsky and Dean (2023, section 10.1) use for two means with unknown standard deviations, with the advice “If the question comes up, do not pool the variances.” It goes with the Welch t-test, whose degrees of freedom “are not always a whole number”.

Worked example: standard error of the difference: manual vs automatic cars

R’s mtcars data record each car’s transmission (am: 0 = automatic, 1 = manual), so the comparison in R is t.test(mpg ~ am, data = mtcars) (R Core Team, 2024).

Step 1: summaries. Automatic: n₁ = 19, x̄₁ = 17.15, s₁ = 3.83. Manual: n₂ = 13, x̄₂ = 24.39, s₂ = 6.17.

Step 2: each mean’s variance. s₁²/n₁ = 0.774 and s₂²/n₂ = 2.925.

Step 3: add and take the square root. SE = √(0.774 + 2.925) = 1.92 mpg.

Step 4: use it. The difference is 24.39 − 17.15 = 7.24 mpg, so t = 7.24 ÷ 1.92 = 3.77 with 18.3 Welch degrees of freedom.

R’s t.test(mpg ~ am, data = mtcars) subtracts in the other order (automatic − manual), so it prints t = −3.77 and the interval −11.28 to −3.21; the standard error is the same.

The pooled version

If you can assume the two populations have the same standard deviation, combine the two sample variances into a pooled standard deviation s_p and use it for both groups:

SEpooled=sp1n1+1n2,sp=(n1−1)s12+(n2−1)s22n1+n2−2SE_{\text{pooled}} = s_p \sqrt{\frac{1}{n_1} + \frac{1}{n_2}}, \qquad s_p = \sqrt{\frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2}}

For the cars, s_p = 4.90 and the pooled SE = 1.76 mpg, with t = 4.11 on 30 degrees of freedom. In R this is t.test(mpg ~ am, data = mtcars, var.equal = TRUE); the documentation says that with var.equal = TRUE “the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used” (R Core Team, 2024). The pooled SE is smaller here because the smaller group (manual cars) has the larger spread, and pooling gives that spread less weight. With equal group sizes the two formulas give the same standard error (the degrees of freedom still differ).

Standard error vs standard deviation

The standard deviation describes the data; the standard error describes the estimate. For the 32 cars, the SD of 6.027 mpg says that individual cars differ by several miles per gallon. The SE of 1.065 mpg says how far the mean of 32 cars is likely to be from the mean of the population they represent.

Sample size separates them. Altman and Bland (2005) write that “The standard error falls as the sample size increases” while “the standard deviation will not tend to change as we increase the size of our sample”. As a what-if: a sample of 128 cars with the same SD of 6.027 would have SE = 6.027 ÷ √128 = 0.533, half of 1.065, because four times the data halves the standard error.

Their rule for choosing: “if we want to say how widely scattered some measurements are, we use the standard deviation. If we want to indicate the uncertainty around the estimate of the mean measurement, we quote the standard error of the mean” (Altman and Bland, 2005).

Margin of error vs standard error

The margin of error is the standard error multiplied by a critical value:

margin of error=critical value×SE,interval=estimate±margin of error\text{margin of error} = \text{critical value} \times SE, \qquad \text{interval} = \text{estimate} \pm \text{margin of error}

The standard error is a property of the estimate; the margin of error also depends on the confidence level you choose. For a 95% interval the critical value is 1.96 from the z table for a proportion (see why 1.96), and a t value from the t table for a mean whose SD comes from the sample.

Altman and Bland (2005) give the large-sample shortcut: “a 95% confidence interval is obtained as the values 1.96×SE either side of the mean”. Our confidence interval calculator shows the SE, the critical value and the margin of error for any level, and how to interpret confidence intervals explains what the interval does and does not mean.

Bootstrap standard error for any statistic

The median, for example, has no simple formula like s/√n. The bootstrap estimates its standard error by resampling: draw B samples of size n from your data with replacement, compute the statistic in each, and take the standard deviation of those B values. In Hesterberg’s (2014) words, “The bootstrap standard error is the sample standard deviation of the bootstrap distribution”.

For the median of the 32 mpg values (19.2 mpg), 10,000 resamples with seed 1974 give a bootstrap standard error of 1.28 mpg. We computed it with the same code as our bootstrap confidence interval tool: paste the mpg values, choose the median and 10,000 resamples, enter seed 1974, and it reports the same value to more decimals. A seeded run depends on the order of the values, so paste them in the data set’s order: 21.0, 21.0, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17.8, 16.4, 17.3, 15.2, 10.4, 10.4, 14.7, 32.4, 30.4, 33.9, 21.5, 15.5, 15.2, 13.3, 19.2, 27.3, 26.0, 30.4, 15.8, 19.7, 15.0, 21.4. The same resamples give a bootstrap SE of the mean of 1.061 mpg. Hesterberg (2014) notes that for the mean the bootstrap runs slightly narrow, by a factor √((n − 1)/n), so its theoretical value here is 1.049 (the same number as dividing by n instead of n − 1), a little below the formula’s 1.065; the gap between 1.061 and 1.049 is random variation from using 10,000 resamples.

Hesterberg (2014) considers 10,000 resamples or more worth using when accuracy matters, and warns that “The ordinary bootstrap tends not to work well for statistics such as the median or other quantiles in small samples”. Treat a bootstrap SE of a median from a small sample as rough. Our guide to what bootstrapping is covers the method in full.

How to report a standard error

Say which measure follows the ± sign. Altman and Bland (2005) point out that a figure such as “69.4±9.3 kg” on its own “gives no indication whether the second figure is the standard deviation or the standard error (or indeed something else)”. A clear sentence:

Mean fuel consumption of the 32 cars was 20.09 mpg (SD 6.027; SE 1.065; 95% CI 17.92 to 22.26).

When the point is precision, a 95% confidence interval is usually more useful than mean ± SE, because mean ± 1 SE is only about a 68% interval for large samples (1 SE either side of a normal curve, against 1.96 SE for 95%). For a difference, give the difference, its interval and the method (Welch or pooled). For a bootstrap SE, give B, the software and the seed.

Common mistakes

Error bars that do not say SD or SE. SE bars are much shorter than SD bars (1.065 against 6.027 here), so a reader who takes one for the other misjudges either the spread or the precision. Label every error bar.

Using n instead of n − 1 in the standard deviation. That gives SE = 1.049 instead of 1.065 for the cars; the gap grows as n shrinks.

Calling the SE the variability of the data. A small SE means a precise mean, not that the individual values are similar. Use the SD to describe spread.

Using the proportion formula when p̂ is 0 or 1, or n is small. With 0 successes in 20 trials (a hypothetical case), the formula gives SE = 0, which suggests perfect certainty. Illowsky and Dean (2023, section 8.3) note that “Studies have shown that the resulting estimation of the standard deviation can be flawed”, and their condition (np̂ and n(1 − p̂) both greater than five) already rules this case out. They fix it with the plus-four method (pretend there are two more successes and two more failures); the Wilson score interval is another standard fix, and our confidence interval calculator gives 0 to 0.161 for that case.

Treating paired data as two groups. Before-and-after measurements on the same people need the standard error of the differences, s_d/√n, not the two-sample formula.

Pooling by default. The pooled formula assumes equal population standard deviations. When unsure, use the unpooled SE with the Welch degrees of freedom, R’s default.

Where to go next

Compute the standard error and the interval for your own data in our confidence interval calculator, and watch the standard error shrink with n in the sampling distribution simulator. For statistics without a formula, read bootstrap confidence intervals. More guides are on the statistics hub.

References

  1. Altman, D. G. & Bland, J. M. (2005). Standard deviations and standard errors. BMJ, 331(7521), 903.
  2. Illowsky, B. & Dean, S. (2023). Introductory Statistics 2e, Section 7.1: The Central Limit Theorem for Sample Means (Averages). OpenStax, Rice University.
  3. Illowsky, B. & Dean, S. (2023). Introductory Statistics 2e, Section 8.3: A Population Proportion. OpenStax, Rice University.
  4. Illowsky, B. & Dean, S. (2023). Introductory Statistics 2e, Section 10.1: Two Population Means with Unknown Standard Deviations. OpenStax, Rice University.
  5. Hesterberg, T. (2014). What Teachers Should Know about the Bootstrap: Resampling in the Undergraduate Statistics Curriculum (preprint, longer version). arXiv preprint arXiv:1411.5279.
  6. R Core Team (2024). mtcars: Motor Trend Car Road Tests (datasets package documentation). R Foundation for Statistical Computing (R 4.3.3).
  7. R Core Team (2024). t.test: Student's t-Test (stats package documentation). R Foundation for Statistical Computing (R 4.3.3).

Try it

Related reading