No history yet

Introduction to Linear Regression

Finding the Pattern

Linear regression is a way to find a straight-line relationship between two things. Imagine you're selling ice cream. You probably sell more on hot days than on cold ones. Linear regression helps you figure out exactly how much more you might sell as the temperature rises.

It takes a bunch of data points, like daily temperature and daily sales, and draws the best possible straight line through them. This line represents the simplest relationship between the two variables.

Lesson image

The main goal is to model a relationship so we can make predictions. If we know the temperature tomorrow, we can use our line to estimate how much ice cream we'll sell. It's a fundamental tool for forecasting and understanding how one variable affects another.

Linear regression analysis is used to predict the value of a variable based on the value of another variable.

Real-World Uses

You can find linear regression at work in many different fields.

In business, a company might use it to predict product sales based on its advertising budget. How much do sales increase for every extra $1,000 spent on ads?

In finance, an investor could model the relationship between a company's stock price and the overall market's performance.

In healthcare, a doctor might use a patient's weight to predict their blood pressure. The applications are everywhere because simple, linear relationships are surprisingly common.

The Math Behind the Line

The straight line at the heart of linear regression comes from a familiar formula from algebra.

Lesson image

Statisticians write the formula with slightly different notation. The model tries to predict a dependent variable (often called yy) using an independent variable (xx). The relationship is defined by two parameters: the intercept and the slope.

y=β0+β1x+ϵy = \beta_0 + \beta_1 x + \epsilon

Let's break that down:

  • yy is the variable we are trying to predict (e.g., ice cream sales).
  • xx is the variable we are using to make the prediction (e.g., temperature).
  • β1\beta_1 is the slope. It tells us how much yy is expected to increase when xx goes up by one unit.
  • β0\beta_0 is the intercept. It's the predicted value of yy when xx is zero.
  • ϵ\epsilon (epsilon) is the error term. It represents the part of yy that our model can't explain. Real-world data is never perfectly clean, so this term accounts for the random noise or variation that our line doesn't capture.

The goal of linear regression is to find the values for the intercept (β0\beta_0) and the slope (β1\beta_1) that create the best-fitting line for the data.

By finding these values, we can plug in any new xx value and get a prediction for yy. This simple but powerful idea is a cornerstone of statistics and data analysis.