Linear Regression

Simple linear regression, assumptions, interpretation

5 free lessons available

Start here

What is Linear Regression?

How do you quantify the relationship between two variables to make predictions? Linear Regression provides a structured way to model this relationship, allowing us to understand how changes in one variable might influence another and to forecast future outcomes.

Spotting Trends in Your Data

When examining data, we often look for clear patterns. If we observe that as one variable increases, another tends to increase or decrease consistently, we might suspect a linear relationship. This means the relationship can be approximated by a straight line, making it easier to interpret and use for predictions.

Hours Studied vs. Exam Score with Regression Line
This scatter plot shows the relationship between hours a student studied and their corresponding exam score. A red line, representing the linear regression model, is drawn through the data points to illustrate the general trend.
Loading chart...
Key Insight: A clear positive linear trend exists: more hours studied generally lead to higher exam scores, summarized by the regression line.

The 'Best Fit' Line: Minimizing Errors

The core idea behind linear regression is to find the 'line of best fit' for the data. This isn't just any line; it's the one that minimizes the overall difference between the actual observed values and the values predicted by the line. These differences are called errors or residuals, representing how far off our predictions are from reality.

Exam Scores with Prediction Errors (Residuals)
This scatter plot shows the same data points and regression line as before, but now includes vertical dashed lines from each data point to the regression line. These lines visually represent the prediction errors, or residuals, for each observation.
Loading chart...
Key Insight: The vertical dashed lines illustrate the residuals: the distance between each actual exam score and the score predicted by the regression line.
Check Your Understanding
What is the primary goal when determining the 'line of best fit' in linear regression?

Formally Defining Linear Regression

Linear Regression
A statistical method used to model the linear relationship between a dependent variable (the outcome you want to predict) and one or more independent variables (the predictors). Its objective is to find the line that best describes this relationship, allowing for prediction of continuous outcomes.
Example: Predicting a student's final exam score (dependent variable) based on the number of hours they studied (independent variable).

The Linear Regression Equation

📐 Simple Linear Regression Equation

y=β0+β1x+εy = \beta_0 + \beta_1 x + \varepsilon

Where:
- yy: The dependent variable (the outcome being predicted)
- xx: The independent variable (the predictor)
- β0\beta_0: The intercept (the predicted value of yy when x=0x=0)
- β1\beta_1: The slope (the change in yy for a one-unit change in xx)
- ε\varepsilon: The error term (the residual, representing unobserved factors and random variability)

This equation is the mathematical backbone of simple linear regression, which involves only one independent variable. The dependent variable yy is what we are trying to predict, such as a house price. The independent variable xx is what we use to make that prediction, like the house's square footage. The intercept β0\beta_0 is the baseline value of yy when xx is zero, while the slope β1\beta_1 quantifies how much yy changes for every unit increase in xx. Finally, the error term ε\varepsilon accounts for all the variability in yy that the model cannot explain, including random noise and other unmeasured factors.

Where Linear Regression Shines

Linear regression is a versatile tool used across many industries for both prediction and understanding relationships. For instance, real estate analysts use it to predict house prices based on features like size, number of bedrooms, and location. Businesses forecast sales by modeling the relationship between advertising spend and revenue. In agriculture, it helps estimate crop yield based on factors like rainfall and fertilizer use. Its simplicity and interpretability make it a popular choice for initial data exploration and building foundational predictive models.

Key Takeaways
  • Linear Regression models the linear relationship between a dependent variable and one or more independent variables.

  • Its primary objective is to find the 'line of best fit' that minimizes the sum of squared prediction errors (residuals).

  • The model is represented by an equation: y=β0+β1x+εy = \beta_0 + \beta_1 x + \varepsilon, where β0\beta_0 is the intercept and β1\beta_1 is the slope.

  • It's widely used for predicting continuous outcomes and understanding how variables relate to each other.

  • Linear Regression provides a straightforward way to quantify relationships and make predictions, directly answering how to model data for forecasting.

Open this lesson on its own page →

Ready to keep this from fading?

Bitelrn turns lessons like this into a full course — quizzes, a knowledge map, and spaced review.

Get started free