2026-06-01

Linear Regression

Predicting Sales Using Advertising Spending

  • One of the most common statistical methods
  • Used in business, finance, healthcare, and science
  • Helps predict outcomes using historical data

Linear Regression Model

The simple linear regression model is:

\[ Y = \beta_0 + \beta_1X + \epsilon \]

Where:

  • \(Y\) = response variable
  • \(X\) = predictor variable
  • \(\beta_0\) = intercept
  • \(\beta_1\) = slope
  • \(\epsilon\) = error term

Interpretation

The prediction equation is:

\[ \hat{Y} = \beta_0 + \beta_1X \]

Example:

\[ Sales = 40 + 2(Advertising) \]

If advertising increases by $1, sales increase by approximately $2.

Example Dataset

sales <- data.frame(
  advertising = c(5,10,15,20,25,30,35,40),
  sales = c(50,60,75,80,90,100,110,120)
)

sales
##   advertising sales
## 1           5    50
## 2          10    60
## 3          15    75
## 4          20    80
## 5          25    90
## 6          30   100
## 7          35   110
## 8          40   120

Scatterplot

Regression Line

Interactive Plot

R Code Example

model <- lm(sales ~ advertising,
            data = sales)

coef(model)
## (Intercept) advertising 
##   41.428571    1.964286

Conclusions

  • Advertising and sales move together.
  • Regression can predict future sales.
  • Regression is useful in business analytics.