Table of contents
Upskilling Made Easy.
Simple Linear Regression with a Quirky Example
Published 12 May 2025
1.7K+
5 sec read
Simple linear regression serves as a powerful tool for identifying and quantifying relationships between two continuous variables. To illustrate its concept further, let's dive into a quirky and relatable example involving everyone's favorite topic: ice cream sales and temperature! This example will not only clarify the concepts of simple linear regression but also make it a delightful read.
Imagine you're the owner of a popular ice cream parlor called "Scoop Heaven." You've noticed a trend: as the temperature rises, so do your ice cream sales. But how strong is that relationship? To answer this question, you decide to analyze historical data from the past summer.
You collect data for 10 sunny days, recording the average temperature (in degrees Fahrenheit) and the corresponding number of ice cream cones sold. Here’s a sample dataset:
Day | Temperature (°F) | Ice Cream Cones Sold |
---|---|---|
1 | 70 | 50 |
2 | 75 | 65 |
3 | 80 | 85 |
4 | 85 | 100 |
5 | 90 | 130 |
6 | 95 | 140 |
7 | 100 | 180 |
8 | 72 | 55 |
9 | 78 | 70 |
10 | 88 | 120 |
You've plotted these data points on a graph, with temperature on the x-axis and ice cream sales on the y-axis. You notice that as the temperature increases, so do the sales, which suggests a linear relationship. But how can you quantify this relationship mathematically? Enter simple linear regression!
The line of best fit will be computed using the Ordinary Least Squares (OLS) method, which minimizes the squared differences between the observed values and the values predicted by the linear regression model.
The linear equation can be expressed as:
Y = mX + c
Where:
For the model to provide reliable results, it must satisfy certain assumptions:
After analyzing the data and fitting the linear regression model, suppose you find:
Thus, the linear equation becomes:
Ice Cream Cones Sold = -20 + 2 * Temperature
With this equation, you can now predict how many cones you will sell based on the day's temperature. For example, on a scorching 95°F day:
Predicted Sales = -20 + 2 * 95 = 170
So, you might expect to sell approximately 170 ice creams!
Through this quirky ice cream sales example, we've navigated the basics of simple linear regression, uncovering the power of data analysis in predicting sales based on environmental factors like temperature. Not only did we explore how to define variables and fit a model, but we also reviewed essential assumptions that ensure our analysis is valid.
As data-driven decision-making grows in importance across industries, mastering techniques like simple linear regression will equip you to extract actionable insights and make informed predictions.
Happy scooping (and coding)!