Introduction to Regression

Learn how to find the best-fitting line through data points and make predictions using linear regression.

Advanced25 minLesson

Definition

Linear regression is a statistical method used to find the straight line that best fits a set of data points. This line is called the line of best fit or regression line.
The equation of a regression line is:
where:
  • is the slope (how steep the line is)
  • is the y-intercept (where the line crosses the y-axis)
  • is the input variable (independent variable)
  • is the predicted output (dependent variable)
The goal of regression is to minimize the total distance between the data points and the line, allowing us to make predictions for new values of .

Try it now

What does the represent in the equation ?

Worked Examples

A study shows that for every additional hour of studying, test scores increase by 5 points. If a student who studies 0 hours scores 50 points, what is the regression equation?

1

Identify the slope

Score increases by 5 points per hour of studying

2

Identify the y-intercept

When hours, the score is 50 points

3

Write the equation

Substitute and into

Common Mistakes

Confusing the order of subtraction in the slope formula

Why it's wrong: Using instead of gives the reciprocal of the correct slope.

Correct: Remember: slope is 'rise over run' - the change in (vertical) divided by the change in (horizontal).

Extrapolating too far beyond the data

Why it's wrong: The regression line is only reliable within the range of your data. Predicting far outside this range can lead to unrealistic results.

Correct: Be cautious about predictions for values much larger or smaller than your original data points.

Assuming correlation means causation

Why it's wrong: Just because two variables are related (correlated) does not mean one causes the other.

Correct: Regression shows relationships, but additional analysis is needed to establish causation.

Interactive Visual

Linear Function Explorer

y = x
Slope (m)1
Y-Intercept (b)0
b
run
rise
xy
-2-2
-1-1
00
11
22

Interactive Sandbox

Interactive Grapher

Try these examples:

y = 2x + 1

m=2, b=1

Expression Calculator

Try these:

History

No calculations yet

Practice Problems

16 problems
Problem 1 of 16
Easy

What does the represent in the equation ?

Why It Matters

Linear regression is one of the most widely used tools in data science and statistics:
  • Business: Predicting sales based on advertising spending
  • Medicine: Estimating drug dosage based on patient weight
  • Economics: Forecasting GDP growth from various indicators
  • Sports: Projecting athlete performance from training metrics
  • Science: Modeling relationships between variables in experiments
Understanding regression helps you make data-driven decisions and predictions based on real evidence rather than guesswork.

Real World Applications

Predicting House Prices

Real estate analysts use regression to estimate home values based on factors like square footage, number of bedrooms, and location.

Example:

If homes sell for approximately 150 dollars per square foot with a base price of 50000 dollars, the equation might be , where is square footage.

1Try It Yourself

A real estate model shows: , where is square feet and is price in dollars.

What is the predicted price for a 1500 square foot home?

Step 1: Write the mathematical expression

Substitute into the equation:

Fuel Efficiency Analysis

Automotive engineers use regression to understand how car weight affects fuel consumption.

Example:

Data might show that fuel efficiency decreases by 0.005 km/L for every kilogram of additional weight.

2Try It Yourself

A car model shows: , where is weight in kg and is fuel efficiency in km/L.

What efficiency is predicted for a car weighing 1200 kg?

Step 1: Write the mathematical expression

Calculate:

Key Takeaways

  • 1Linear regression finds the straight line that best fits a set of data points
  • 2The regression equation is , where is the slope and is the y-intercept
  • 3Slope is calculated as (rise over run)
  • 4Once you have the equation, you can make predictions by substituting values for
  • 5Regression shows correlation, but correlation does not imply causation

Frequently Asked Questions

Real data rarely falls perfectly on a line. The regression line minimizes the total squared distance from all points to the line. Some points will be above the line, some below - this is normal!
Real data rarely falls perfectly on a line. The regression line minimizes the total squared distance from all points to the line. Some points will be above the line, some below - this is normal!
The value (coefficient of determination) measures how well the line fits. It ranges from 0 to 1 - higher values mean better fit. You will learn more about this in the lesson on correlation.
Linear regression only works for straight-line relationships. For curved relationships, you need polynomial regression or other advanced methods.

Glossary

Linear regression
A statistical method for finding the best-fitting straight line through data points
Line of best fit
The straight line that minimizes the distance between itself and all data points
Slope
The steepness of the line, representing the rate of change ( in )
Y-intercept
The point where the line crosses the y-axis ( in )
Prediction
Using the regression equation to estimate for a given value of
Independent variable
The input variable () that we use to make predictions
Dependent variable
The output variable () that we are trying to predict

More in This Topic