No history yet

Regression Basics

Predicting the Future

How much should a company spend on advertising? If you study for five more hours, what will your exam score be? How does the temperature outside affect ice cream sales? These are questions about relationships between different factors.

Regression is a statistical tool that helps us understand and quantify these relationships. Specifically, it allows us to predict a continuous numerical outcome based on one or more other variables. Think of it as finding a pattern in the data that you can use to make educated guesses.

The core idea of regression is to model the relationship between variables to predict an outcome.

The Main Characters

In any regression scenario, there are two main types of variables. Let's use the example of predicting exam scores based on hours studied.

Dependent Variable

adjective

This is the main thing you are trying to predict or explain. It's also called the response or target variable. Its value depends on other factors.

The other type of variable is the one we use to make the prediction.

Independent Variable

adjective

This is the variable you believe has an impact on the dependent variable. It's the input, sometimes called the predictor or feature. We use its value to predict the outcome.

ScenarioIndependent VariableDependent Variable
Predicting house pricesSize of the house (sq. ft.)House price
Estimating crop yieldAmount of rainfallKilograms of corn harvested
Forecasting company salesAdvertising budgetQuarterly sales revenue

Finding the Line of Best Fit

Imagine you collected data on several students. You plot their hours studied on the x-axis and their exam scores on the y-axis. You'd likely see a scatter of points. They won't form a perfect line, but you might notice a trend: as study hours increase, so do scores.

Linear regression works by drawing a single straight line through this scatter of points. This line doesn't have to hit any of the points exactly. Instead, it's drawn in a way that minimises the overall distance from all the points to the line. This is called the or regression line. It represents the general relationship between the two variables.

Lesson image

Every straight line can be described by a simple equation. It's the recipe the model uses to turn an independent variable (x) into a prediction for the dependent variable (y).

y=β0+β1xy = \beta_0 + \beta_1 x

In our example, the slope (eta_1) would represent the average increase in exam score for each additional hour of studying. The intercept (eta_0) would be the predicted score for someone who didn't study at all.

Once we have this line, making a prediction is easy. If you want to know the likely exam score for someone who studied for 7 hours, you just find '7' on the x-axis, go up to the line, and see what value it corresponds to on the y-axis. The line gives us a prediction for any value of our independent variable, even ones we haven't seen before.

Quiz Questions 1/4

What is the primary goal of regression analysis?

Quiz Questions 2/4

In the context of predicting ice cream sales based on the daily temperature, the 'ice cream sales' is the...

That's the fundamental idea of linear regression. It's a simple but powerful way to find and use the linear relationships hidden in data.