Lesson 10 — Time Series for Business/Economics
(trend, seasonality, forecasting baselines, and honest evaluation)
Why this matters (motivation)¶
Business and economics are full of time-indexed questions:
How will sales evolve next month?
Is inflation accelerating or stabilizing?
Are customer visits seasonal?
Did a policy change coincide with a shift in a trend?
Time series analysis gives a disciplined way to:
describe patterns over time,
and forecast future values with transparent assumptions.
Time series mindset: time is not just another variable¶
Unit of observation (again)¶
Be explicit:
daily sales (store-day),
monthly inflation (country-month),
quarterly GDP (country-quarter).
This determines what “seasonality” means and what forecasts are useful.
Describing time series: the three components¶
A useful conceptual decomposition: [ y_t = \text{trend}_t + \text{seasonality}_t + \text{noise}_t ] (or multiplicative forms when growth is proportional).
Trend¶
Long-run movement (growth/decline).
Seasonality¶
Regular cycles (day-of-week, monthly, quarterly).
Noise (irregular component)¶
Random shocks, measurement noise, one-off events.
Forecasting as a benchmark game¶
Baseline 1: naïve¶
[ \hat{y}_{t+1} = y_t ]
Baseline 2: seasonal naïve¶
[ \hat{y}{t+h} = y{t+h-s} ] where (s) is seasonal period (e.g., 12 for monthly with yearly seasonality).
Baseline 3: moving average¶
Forecast using recent average: [ \hat{y}{t+1} = \frac{1}{k}\sum{i=0}^{k-1} y_{t-i} ]
How to evaluate forecasts (practically)¶
Time-based splitting¶
Train on early period
Test on later period (“future”)
Example:
Train: 2010–2019
Test: 2020–2023
Metrics (choose one or two and interpret)¶
MAE (mean absolute error): easy to interpret in units
RMSE (root mean squared error): penalizes large errors more
MAPE (percentage error): intuitive but unstable when values near zero
Visual communication for time series¶
Minimum set of plots that actually helps:
Line plot of the series (with clear time axis)
Rolling average (optional) to show trend
Seasonality view (e.g., month-of-year average or day-of-week average)
Forecast plot: actual vs predicted for the test window
Mini case options (choose one)¶
Option A (business): sales forecasting¶
Weekly or monthly sales
Forecast next month/quarter
Use seasonal naïve if clear seasonality
Option B (economics): OWID time series¶
Use an OWID dataset that is time-indexed (country-year, country-month, etc.). Examples:
CO₂ emissions per capita
GDP per capita
energy consumption
inflation (if available in your chosen dataset)
Focus: describe trend/seasonality and create a baseline forecast.
Mini-lab (Google Colab)¶
In-class checkpoints (data preparation)¶
Load a time series dataset with a clear time column.
Sort by time and set the time column correctly (datetime or integer year).
Plot the full time series and write one sentence describing the main pattern.
In-class checkpoints (decomposition / pattern checks)¶
Compute a rolling average (choose a window and justify).
If seasonal frequency exists (e.g., monthly), compute a seasonal profile:
average by month-of-year or day-of-week.
In-class checkpoints (forecast baselines)¶
Create a train/test split by time (e.g., last 20% as test).
Implement at least two baselines:
naïve
moving average OR seasonal naïve
Plot predictions vs actual in the test window.
In-class checkpoints (evaluation)¶
Compute MAE and RMSE for each baseline on the test window.
Choose the “best” baseline and justify using both:
metric evidence, and
business reasoning (what errors matter?).
Submission (after class)¶
Colab link (view permission) or PDF export.
Include:
your forecast plot,
metric table,
and a short “forecast memo” (headline + caveat + what could break it).
AI check (responsible use for time series)¶
Good prompt examples
“Write Python code to split a time series into train/test by date and compute MAE.”
“Implement a seasonal naïve forecast for monthly data with period 12.”
“Suggest a clear plot to compare forecasts vs actual in the test period.”
Bad prompt example
“Pick the best model and guarantee the forecast is accurate.”
Review questions (quiz / reflection)¶
Why should train/test splits be done by time for forecasting?
What is a naïve forecast, and why is it a strong baseline?
When might MAPE be misleading?
Give one factor that could cause a forecast to fail (structural break).