What Is Simple Linear Regression?

Simple linear regression is a statistical method used to study the relationship between two variables.

  • Explanatory variable (x): hours studied
  • Response variable (y): exam score
  • The goal is to use x to predict y.
  • A straight line is used to describe the relationship.

The data in this presentation are example data created for demonstration.

The Regression Equation

The general simple linear regression model is:

\[ Y = \beta_0 + \beta_1X + \epsilon \]

Where:

  • \(Y\) = response variable
  • \(X\) = explanatory variable
  • \(\beta_0\) = intercept
  • \(\beta_1\) = slope
  • \(\epsilon\) = random error

The fitted regression line is written as:

\[ \hat{Y} = b_0 + b_1X \]

Example Data

We will look at the relationship between study time and exam scores.

The data suggest that students who study more hours tend to have higher exam scores.

Hours Studied Exam Score
1 55
2 58
3 65
4 70
5 76
6 82
7 86
8 90
9 94

Scatterplot and Regression Line

The plot shows a positive linear relationship. As study hours increase, exam scores generally increase.

Interpreting the Slope

For this example, the fitted regression line is approximately:

\[ \hat{Y} = 49.79 + 4.82X \]

The slope is approximately 4.82.

This means that for each additional hour studied, the predicted exam score increases by about 4.82 points, on average.

The intercept is about 49.79, which is the predicted score when study time is zero hours.

Residuals

A residual is the difference between an observed value and its predicted value:

\[ e_i = y_i - \hat{y}_i \]

A residual tells us how far an observation is from the regression line.

The residuals are centered around zero, which is useful when checking whether a linear model is reasonable.

R Code

The lm() function creates the simple linear regression model.

# Create the regression model
model <- lm(score ~ hours, data = study_data)

# Display the model results
summary(model)

# Create a scatterplot with a regression line
ggplot(study_data, aes(x = hours, y = score)) +
  geom_point() +
  geom_smooth(method = "lm")

R makes it easy to create the model and visualize the relationship.

Interactive Plotly Graph

Move your mouse over the points to see the study hours and exam score.

Conclusion

Simple linear regression helps describe and predict the relationship between two variables.

Key points:

  • The slope describes the expected change in \(Y\) for a one-unit increase in \(X\).
  • The intercept is the predicted value when \(X = 0\).
  • Scatterplots help visualize the relationship.
  • Residual plots help evaluate the fitted model.
  • R can create regression models and graphs quickly.

In this example, more study time was associated with higher predicted exam scores.