2026-10-22

The Question

Do students who study more hours tend to earn higher exam scores?

  • We will explore this question using correlation.
  • We will visualize the pattern and calculate a correlation coefficient.
  • The dataset contains 15 fictional students, created only to demonstrate the statistical idea.
These illustrative values are not observations from a real class.

Understanding Correlation

Correlation describes the direction and strength of a linear relationship between two numerical variables.

  • Positive: as one variable increases, the other tends to increase.
  • Negative: as one increases, the other tends to decrease.
  • Near zero: little linear relationship is visible.

Correlation does not prove cause and effect.

The Mathematics: Pearson’s r

Pearson’s sample correlation coefficient is

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

  • \(x_i\) = study hours and \(y_i\) = exam score.
  • \(\bar{x}\) and \(\bar{y}\) are the sample averages.
  • \(-1\leq r\leq 1\). Values near \(1\) indicate a strong positive linear association.

The Mathematics: A Trend Line

We can also summarize the overall trend with a simple regression line:

\[\widehat{y}=b_0+b_1x\]

For these example data, the fitted line is approximately

\[\widehat{\text{score}}=46+5.2\times \text{hours}\]

  • The slope is the expected score difference for one additional study hour in this example.
  • A fitted line describes association, not necessarily a causal effect.

Using R for the Analysis

The code below calculates the correlation and fits a line:

r <- cor(students$hours, students$score)
model <- lm(score ~ hours, data = students)
summary(model)

Result: Pearson’s \(r\) is approximately 0.97, a strong positive correlation in this fictional dataset.

Visualization 1: Study Hours vs. Scores

Interpretation: the points generally rise as study hours increase.

Visualization 2: A Different View

This histogram shows the spread of scores, but not their relationship to hours.

Interactive Graph: Explore Each Point

Hover over points to see their illustrative hours and scores.

What Did We Learn?

  • The fictional sample has a strong positive linear association (\(r\approx\) 0.97).
  • Both the scatterplot and the numerical coefficient tell the same story.
  • The histogram describes scores alone, while the scatterplot shows the relationship.
  • We cannot conclude that extra study hours caused higher scores.

Limits and Conclusion

Limitations: The data are invented for practice; the sample is small and other factors such as previous knowledge and sleep are not included.

Conclusion: Correlation is a useful first step for understanding how two numerical variables move together. A responsible analysis also considers context and possible confounding factors.

Source: Original simulated classroom example; calculations and figures generated in R using ggplot2 and plotly.