In this example, we analyze the impact of different advertising channels (TV, radio, and online ads) on product sales.
This example demonstrates the application of econometrics in marketing analysis.
Problem Statement
We aim to estimate the following relationship:
$$
\text{Sales} = \beta_0 + \beta_1 \cdot \text{TV} + \beta_2 \cdot \text{Radio} + \beta_3 \cdot \text{Online} + \epsilon
$$
where:
- $ \text{Sales} $: Units sold.
- $ \text{TV}, \text{Radio}, \text{Online} $: Advertising budgets in respective channels.
- $ \beta_0, \beta_1, \beta_2, \beta_3 $: Coefficients to be estimated.
Python Implementation
1 | import numpy as np |
Explanation of Code
Synthetic Data Generation:
- Simulates advertising budgets and their effect on sales.
- Adds random noise $ \epsilon $ to make the data realistic.
Regression Analysis:
- OLS (Ordinary Least Squares) is used to estimate the coefficients $( \beta_0, \beta_1, \beta_2, \beta_3 $).
Visualizations:
- Bar Plot: Displays the estimated impact (coefficients) of each advertising channel on sales.
- Pairplot: Shows scatter plots with regression lines to visualize individual relationships.
Key Outputs
- Regression Summary:
- Coefficients:
- Quantify the effect of each advertising channel on sales.
- R-squared:
- Indicates how much of the variability in sales is explained by the model.
- Coefficients:
OLS Regression Results
==============================================================================
Dep. Variable: Sales R-squared: 0.600
Model: OLS Adj. R-squared: 0.588
Method: Least Squares F-statistic: 48.08
Date: Tue, 03 Dec 2024 Prob (F-statistic): 4.65e-19
Time: 03:01:43 Log-Likelihood: -368.43
No. Observations: 100 AIC: 744.9
Df Residuals: 96 BIC: 755.3
Df Model: 3
Covariance Type: nonrobust
==============================================================================
coef std err t P>|t| [0.025 0.975]
------------------------------------------------------------------------------
const 0.9997 3.278 0.305 0.761 -5.507 7.507
TV 0.3416 0.033 10.267 0.000 0.276 0.408
Radio 0.4417 0.068 6.474 0.000 0.306 0.577
Online 0.3098 0.114 2.727 0.008 0.084 0.535
==============================================================================
Omnibus: 5.375 Durbin-Watson: 2.376
Prob(Omnibus): 0.068 Jarque-Bera (JB): 4.964
Skew: -0.402 Prob(JB): 0.0836
Kurtosis: 3.738 Cond. No. 205.
==============================================================================
Notes:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
- Bar Plot:
- Highlights the relative importance of each advertising channel.

- Pairplot:
- Provides an intuitive visualization of relationships between budgets and sales.

This example can be extended to include interaction terms (e.g., $ \text{TV} \times \text{Online} $) or to model diminishing returns on advertising investments.








