The Question

  • A little brown bat sleeps about 20 hours a day.
  • A giraffe sleeps less than 2 hours a day.

Does an animal’s body size determine how long it sleeps?

How statistics can help:

  • Correlation: how strongly are size and sleep related?
  • Regression: how much does sleep change as animals get bigger?
  • Hypothesis test: could the pattern just be chance?

The Data

The msleep dataset comes with the ggplot2 package. It has 83 mammals.

The two variables I use:

  • bodywt: body weight in kilograms
  • sleep_total: hours of sleep per day

Body weight goes from 0.005 kg (a shrew) to 6,654 kg (an African elephant).

First Look

Most animals are squashed on the left because a few giant animals stretch the axis. The correlation is only r = -0.31.

Using a Log Scale

Each step of 1 on the x-axis means 10 times heavier. Now the downward trend is clear: r = -0.57.

Math: Correlation

First I take the log of body weight:

\[x = \log_{10}(\text{body weight})\]

The correlation \(r\) measures how strong a straight-line relationship is:

\[r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}}\]

  • \(r\) is always between \(-1\) and \(1\)
  • Close to \(-1\) means a strong negative relationship
  • Close to \(0\) means no linear relationship

Math: Regression

The regression line:

\[\hat{y} = \beta_0 + \beta_1 x\]

  • \(\hat{y}\) is the predicted hours of sleep
  • \(\beta_1\) is the slope: how much sleep changes when \(x\) goes up by 1

To check if the relationship is real, we test:

\[H_0: \beta_1 = 0 \quad \text{vs.} \quad H_a: \beta_1 \neq 0\]

A small p-value means the slope is very unlikely to be zero.

R Code

library(ggplot2)

# Take the log of body weight
sleep <- msleep
sleep$log_body <- log10(sleep$bodywt)

# Correlation between log body weight and sleep
cor(sleep$log_body, sleep$sleep_total)

# Fit the regression line
model <- lm(sleep_total ~ log_body, data = sleep)
summary(model)

# Plot the points with the regression line
ggplot(sleep, aes(x = log_body, y = sleep_total)) +
  geom_point() +
  geom_smooth(method = "lm")

Results

  • Correlation: r = -0.57
  • Slope: -1.79
  • p-value: 2e-08
  • R-squared: 0.32

What this means:

  • Every time an animal is 10 times heavier, it sleeps about 1.8 fewer hours per day.
  • The p-value is very small, so the relationship is not just chance.
  • But body size explains only about 32% of the differences in sleep.

Interactive Plot

Hover over a point to see which animal it is. The small animals on the left sleep the most.

What Did We Learn?

  • Bigger animals tend to sleep less. The correlation is -0.57, and the p-value is very small.
  • The log scale helped. On the normal scale, a few giant animals hid the pattern.
  • Body size does not fully determine sleep. It explains only about 32% of the differences. Diet and lifestyle probably matter too.
  • Correlation is not causation. Being big may not cause less sleep. For example, large plant-eaters may need to stay awake longer to eat.

Answer: Body size is a clue to how long an animal sleeps, but it is not the whole story.