What Are Descriptive Statistics?

Descriptive statistics summarize and describe the main features of a dataset.

Three common measures are:

  • Mean: the arithmetic average
  • Median: the middle value
  • Standard deviation: how spread out the values are

In this presentation, we use the built-in mtcars dataset and focus on the variable mpg (miles per gallon).

Mean

The sample mean is calculated by

\[ \bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i \]

where:

  • \(x_i\) is each observation
  • \(n\) is the number of observations
  • \(\bar{x}\) is the sample mean

For the mtcars dataset:

## [1] 20.09

The average fuel efficiency is about 20.09 mpg.

Median

The median is the middle observation after the data are sorted.

For an odd number of observations, the median is the center value.

For an even number of observations:

\[ \text{Median} = \frac{x_{(n/2)} + x_{(n/2+1)}}{2} \]

For the mtcars dataset:

## [1] 19.2

The median fuel efficiency is 19.2 mpg.

Standard Deviation

Standard deviation measures how far observations typically vary from the mean.

The sample standard deviation is

\[ s = \sqrt{\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}} \]

A small standard deviation means the values are clustered near the mean.

A large standard deviation means the values are more spread out.

## [1] 6.03

For mtcars, the standard deviation is about 6.03 mpg.

ggplot #1: Distribution of MPG

The histogram shows that most cars in the dataset have fuel efficiency between about 15 and 25 mpg.

ggplot #2: MPG by Transmission Type

The boxplot allows us to compare the center and spread of MPG values for automatic and manual cars.

Interactive Plotly Plot

This interactive plot shows the relationship between vehicle weight and fuel efficiency.

Example R Code

The following R code calculates the three statistics used in this presentation:

mean(mtcars$mpg)

median(mtcars$mpg)

sd(mtcars$mpg)

We can also summarize them together:

data.frame(
  Mean = mean(mtcars$mpg),
  Median = median(mtcars$mpg),
  Standard_Deviation = sd(mtcars$mpg)
)

Summary

Descriptive statistics help us understand a dataset quickly.

  • The mean describes the average.
  • The median describes the middle value.
  • The standard deviation describes the spread.
  • Histograms and boxplots help visualize distributions.
  • Interactive Plotly graphs make it easier to explore relationships in data.

These tools provide a simple first step before using more advanced statistical methods.