Skip to course content
Free R statistics course

Statistical Data Analytics with R

Unit 03.01: Carry n and the standard error

A group mean without its standard error is a ranking presented as a fact.

Carry n and the standard error through every summary

Grouped summaries invite comparison, and comparison needs uncertainty. The standard error โ€” the standard deviation divided by the square root of n โ€” says how precisely each group's mean is estimated, and it varies enormously between groups of different sizes.

A small group will frequently top a ranking by chance alone. With n of 6 the mean is barely pinned down, so it lands high or low far more often than a large group's does. Adding n and se to the summary is two lines and makes that visible.

This is the descriptive-statistics version of the whole course's argument: an estimate without its uncertainty is not yet a result.

This block summarises three regions of very different sizes.

suppressPackageStartupMessages(library(dplyr))

set.seed(23)
d <- data.frame(
  region = rep(c("North", "South", "East"), times = c(40, 35, 6)),
  spend  = c(rnorm(40, 52, 14), rnorm(35, 48, 12), rnorm(6, 72, 26))
)

summary_table <- d |>
  group_by(region) |>
  summarise(n = n(),
            mean = round(mean(spend), 1),
            sd = round(sd(spend), 1),
            se = round(sd(spend) / sqrt(n()), 2),
            .groups = "drop") |>
  arrange(desc(mean))
print(summary_table)

cat("\nEast has the highest mean and the smallest n.\n")
cat("Its standard error is", summary_table$se[summary_table$region == "East"],
    "against", summary_table$se[summary_table$region == "North"], "for North --\n")
cat("roughly", round(summary_table$se[summary_table$region == "East"] /
                     summary_table$se[summary_table$region == "North"], 1),
    "times as uncertain, from", summary_table$n[summary_table$region == "East"], "observations.\n")
cat("\nCarry n and the standard error, or the ranking reads as settled.\n")

East tops the table at a mean of 61 โ€” from 6 observations, with a standard error of 14.03 against North's 1.89. East's mean is roughly 7.4 times as uncertain as North's. Its standard deviation of 34.4 is nearly three times North's, so the extra uncertainty comes from both the small sample and the wider spread. Without the n and se columns the table reads as a settled ranking.

The mistake this prevents

The mistake is sorting group means and reporting the top one. The smallest group wins that competition far more often than its size deserves.

Takeaway

Include n, the standard deviation and the standard error in every grouped summary you publish. Be explicit when a group is too small to support a comparison.