Menu
Theme
Diploma in Supply Chain Management
Course Content

Time series

Quantitative Methods

Habari Mwanafunzi! Welcome to Time Series Analysis!

Ever wondered how a supermarket like Naivas knows exactly how much bread to stock for the weekend? Or how the government predicts electricity demand for the next year? It’s not magic, it’s math! And the specific tool they use is called Time Series Analysis. Think of yourself as a detective, but instead of clues, you're looking at data collected over time to predict the future. Ready to unlock these secrets? Let's dive in!

Image Suggestion: A vibrant, bustling market scene in Kenya. A young, curious student is looking at a fruit vendor's stall, which is full of produce. The background shows matatus and daily life. The style should be a colorful, optimistic digital painting. The student should look thoughtful, as if pondering how the vendor manages their stock.

What Exactly is a Time Series?

Don't let the fancy name scare you! A time series is simply a set of data points collected at regular time intervals. That's it! The 'time interval' could be anything:

  • Hourly (e.g., number of M-Pesa transactions at an agent shop)
  • Daily (e.g., the price of a 2kg packet of maize flour)
  • Weekly (e.g., a matatu sacco's total revenue)
  • Monthly (e.g., rainfall levels in Kericho)
  • Quarterly (e.g., a company's profit report)
  • Yearly (e.g., the number of tourists visiting the Maasai Mara)

The goal is to analyze this data to understand past patterns and, more excitingly, to forecast what might happen in the future. We are looking for the story the numbers are telling us over time.

The Four Components of a Time Series

Imagine your favourite stew. It has different ingredients that give it a unique flavour. Similarly, a time series has four "ingredients" or components that combine to give us the final data we see. Understanding them is key!

1. Secular Trend (T)

This is the long-term "direction" of the data. Is it generally going up, down, or staying steady over many years? It’s the big picture.

Example: Think about the population of Nairobi. Over the last 30 years, despite some ups and downs, the general trend has been a massive increase. That's a secular trend.

   Population
      ^
      |                /
      |               /
      |              /
      |             /
      |            /
      |___________/____________> Time (Years)

    (ASCII Art: A line showing a general upward movement over time)

2. Seasonal Variation (S)

These are patterns that repeat regularly over a short and fixed period, usually a year. They are predictable because they are tied to seasons, holidays, or specific times of the day.

Example: A shop owner in Mombasa knows that sales of ice cream and sodas will be very high from December to March (hot season and holidays) and lower during the cooler months of June and July. This predictable yearly pattern is a seasonal variation.

    Sales
      ^     /\      /\      /\
      |    /  \    /  \    /  \
      |   /    \  /    \  /    \
      |  /      \/      \/      \
      | /                        \
      |/__________________________> Time (Quarters)

   (ASCII Art: A wave-like pattern showing peaks and troughs at regular intervals)

3. Cyclical Variation (C)

These are also wave-like patterns, but they happen over a longer period, typically more than one year. They are often linked to economic cycles like booms (good times) and recessions (tough times). They are harder to predict than seasonal variations.

Example: The construction industry in Kenya might experience a boom for 5-7 years where many buildings are being constructed, followed by a slowdown for a few years as the market cools off. This long-term wave is a cyclical variation.

4. Irregular Variation (I)

These are the unpredictable, random "shocks" to the data. They are caused by one-off events like natural disasters, political announcements, strikes, or a sudden pandemic. You can't predict them!

Example: A sudden, unexpected country-wide power blackout might cause a sharp, one-day drop in factory production. This is an irregular variation.

Models of Time Series: How the Components Mix

So, how do these four ingredients (T, S, C, and I) come together? We use two main models:

1. Additive Model: Used when the variations are roughly constant over time. The magnitude of the seasonal swing doesn't change as the trend goes up or down.


  Formula: Y = T + S + C + I

Think of a small kiosk whose holiday sales increase by a fixed 5,000 KSh every December, regardless of their overall annual growth.

2. Multiplicative Model: This is more common in real life. It's used when the size of the variations changes in proportion to the trend. As the trend grows, the seasonal swings get bigger.


  Formula: Y = T x S x C x I

Think of a large retailer like Carrefour. Their December sales increase isn't a fixed amount; it's a percentage (e.g., 40%) of their average sales. So as their overall sales trend upwards over the years, the cash value of that 40% increase also gets bigger. This is a multiplicative effect.

Image Suggestion: A clear and simple infographic chart. The main chart shows a jagged time series line. Then, three smaller charts below it show the decomposition: one with a smooth upward trend line (labeled 'Trend'), one with a regular wave (labeled 'Seasonality'), and one with random spikes (labeled 'Irregular'). Arrows should show how they combine to form the main chart.

Let's Get Practical: Calculating the Trend with Moving Averages

One of the most important first steps in time series analysis is to separate the trend from the other components. A popular and simple method is the Method of Moving Averages. It works by "smoothing" out the data to remove the short-term fluctuations.

Let's use an example. Imagine we have the quarterly sales data (in thousands of KSh) for a local hardware store in Nakuru.

Problem: Calculate the 4-point moving averages to find the trend.

Year Quarter Sales (KSh '000)
2022Q1150
2022Q2180
2022Q3210
2022Q4160
2023Q1170
2023Q2200
2023Q3230

Step 1: Calculate the 4-Point Moving Totals

We add the sales for 4 consecutive quarters at a time. The first total will be Q1+Q2+Q3+Q4 of 2022. We place this total in the middle of the four values (between Q2 and Q3).


  Total 1 = 150 + 180 + 210 + 160 = 700
  Total 2 = 180 + 210 + 160 + 170 = 720
  Total 3 = 210 + 160 + 170 + 200 = 740
  Total 4 = 160 + 170 + 200 + 230 = 760

Step 2: Calculate the 4-Point Moving Averages

Now, we just divide these totals by 4.


  Average 1 = 700 / 4 = 175.0
  Average 2 = 720 / 4 = 180.0
  Average 3 = 740 / 4 = 185.0
  Average 4 = 760 / 4 = 190.0

Step 3: Center the Moving Averages (Crucial Step!)

Notice that our averages (175.0, 180.0, etc.) fall between the quarters. To get a value that aligns perfectly with a quarter, we take the average of two adjacent moving averages. This is called "centering".


  Centered MA for Q3 2022 = (175.0 + 180.0) / 2 = 177.5
  Centered MA for Q4 2022 = (180.0 + 185.0) / 2 = 182.5
  Centered MA for Q1 2023 = (185.0 + 190.0) / 2 = 187.5

These centered moving averages (177.5, 182.5, 187.5) give us the estimated trend values for those specific quarters. See how they are much "smoother" than the original sales data? We have removed the seasonal noise to see the underlying growth of the hardware store!

So, Why Does This All Matter?

Understanding time series is a superpower for planning and decision-making!

Real-World Scenario: A farmer in the Rift Valley uses past rainfall data (a time series) to predict the start of the long rains. This helps her decide the best time to plant her maize, increasing her chances of a good harvest. She is using time series analysis to make a critical business decision!

By breaking down data into its components and finding the trend, businesses and organisations can:

  • Forecast Future Sales: Like the hardware store planning its stock.
  • Manage Resources: Like Kenya Power planning for electricity needs.
  • Make Policy Decisions: Like the Central Bank of Kenya using economic data to manage inflation.
  • Plan Budgets: A county government can predict future revenue collection based on past trends.

You have taken the first step to becoming a data detective. Keep practicing, stay curious, and you'll soon be able to find the stories hidden in the numbers. You've got this!

Pro Tip

Take your own short notes while going through the topics.

Previous Probability
KenyaEdu
Add KenyaEdu to Home Screen
For offline access and faster experience