Summary statistics
Section of Descriptive statistics, part of Data analysis
Summary statistics
| Type | Section |
| Taught in | Descriptive statistics |
| Part | Data analysis |
For data x_1,\ldots,x_n, the sample mean \overline x=\frac1n\sum x_i is the average and the sample median is the middle value of the sorted data, or the average of the two middle values when n is even. The median is robust: a single wild value can move the mean anywhere but barely moves the median.
Definition 1 (Sample quantile) A sample p-quantile, for 0<p<1, is a value q_p such that a fraction p of the data is at most q_p. The 0.25, 0.5 and 0.75 quantiles are the first quartile, the median and the third quartile; the p-quantile is also the 100pth percentile.
When no data value sits exactly at the fraction p, software interpolates between neighbours. R’s default, used throughout, puts q_p at position 1+(n-1)p of the sorted data, interpolating linearly.
Definition 2 (Interquartile range) The interquartile range is the difference between the third and first quartiles. It is the width of the central half of the sample.
Definition 3 (Sample variance and standard deviation) The sample variance is s^2=\frac1{n-1}\sum_{i=1}^n(x_i-\overline x)^2, and the sample standard deviation is s=\sqrt{s^2}, in the units of the data.
The divisor n-1 makes s^2 an unbiased estimator of the population variance; the reason is in Statistical inference. The range, largest minus smallest, is the crudest measure of spread, and it can only grow as more data arrive.
Example 1 (The ages of 299 patients) Question. Summarise the patients’ ages.
Solution.
mean(heart$age); median(heart$age) # 60.83 60
quantile(heart$age, c(0.25, 0.75)) # 51 70
IQR(heart$age) # 19
sd(heart$age) # 11.89
range(heart$age) # 40 95The patients are aged 40 to 95. The mean and median are close, 60.8 and 60, so the ages are roughly symmetric. The middle half lies between 51 and 70, an interquartile range of 19 years, and the standard deviation is 11.9 years. For a roughly normal sample the interquartile range is about 1.35 standard deviations; here 19/11.9=1.6, so the ages are a little flatter than normal.
Used in
See also
Sample quantile · Interquartile range · Sample variance and standard deviation · Five-number summary and boxplot · Normal quantile plot · Data table · One categorical variable, and two · One quantitative variable