DEV Community

Cover image for How Time Series Reveal the Future: An Introduction to the ARIMA Model
Mubarak Mohamed
Mubarak Mohamed

Posted on

How Time Series Reveal the Future: An Introduction to the ARIMA Model

Imagine you manage a supermarket. Every Monday, you must decide how much milk, rice, soap, and fruit to order for the week. Too little? Stockouts and unhappy customers. Too much? Excess inventory, waste, and unnecessary costs.
So, how can you predict tomorrow’s demand from yesterday’s purchases?

That’s the realm of time series—data ordered over time (day by day, month by month). And among the most widely used methods to forecast the future, there’s ARIMA — AutoRegressive Integrated Moving Average.
ARIMA is popular because it’s both interpretable and effective across many real-world domains: sales, weather, energy, healthcare, finance, and more.

In this opening article, you will:
learn what a time series is and its components (trend, seasonality, noise);
grasp the intuition behind ARIMA (AR, I, MA) without heavy math;
plot a first series in Python to visually detect these patterns.

Ready? Let’s take it step by step. 👇

Transition

This article is the first episode of the series “Mastering ARIMA for Time Series Analysis and Forecasting.”
The goal is clear: to guide you step by step, from the basics to practical applications on real-world projects.

In every article, you will find:

  • a simplified theoretical section (to understand without heavy math),
  • a hands-on Python example (to directly work with data),
  • a small practical project (to apply your knowledge to a real case). This way, you’ll progress in a logical, gradual, and practical manner.

Simplified Theory (What is a time series? + ARIMA intuition)?

What is a time series?

A time series is a sequence of data collected at regular intervals.
Examples:

  • daily sales in a supermarket,
  • hourly temperature,
  • stock prices every minute,
  • monthly internet subscriptions.

Three main components describe a time series:

  • Trend: the long-term overall direction. Example: gradual increase in internet subscribers.
  • S*easonality:* recurring, regular fluctuations. Example: ice cream sales peaking every summer.
  • Noise: unpredictable, random variations. Example: a sudden sales spike due to an unexpected event.

The intuition behind ARIMA
The ARIMA model combines three simple yet powerful ideas:

  • AR (Auto-Regressive): future values depend on past values. Example: today’s sales are partly influenced by yesterday’s sales.
  • I (Integrated): to make the series more stable, we remove trends through differencing (computing the changes between periods).
  • MA (Moving Average): future values adjust based on past forecast errors.

👉 In short:
ARIMA = memory of the past + trend stabilization + error correction.

Hands-on Python

Before diving into ARIMA, let’s take the first step: visualizing a time series.
We’ll use the famous AirPassengers dataset (monthly airline passengers from 1949 to 1960).

import pandas as pd
import matplotlib.pyplot as plt

# Load AirPassengers dataset
url = "dataset/airline-passengers.csv"
data = pd.read_csv(url, parse_dates=['Month'], index_col='Month')

# Preview first rows
print(data.head())

# Visualization
plt.figure(figsize=(10,5))
plt.plot(data, label='Number of passengers')
plt.title("AirPassengers - Monthly Airline Passengers (1949-1960)")
plt.xlabel("Date")
plt.ylabel("Passengers")
plt.legend()
plt.show()

Enter fullscreen mode Exit fullscreen mode


Expected result:

A curve showing:

  • a rising trend (more passengers over the years),
  • a yearly seasonality (summer peaks, winter drops). This first visualization is essential: it helps us spot the patterns that ARIMA will later model.

Real-world use cases

Time series models like **ARIMA **are widely used to forecast the future based on past data. Here are some concrete examples:

Finance:

  • Predict stock prices or market indices.
  • Anticipate trends to make better investment decisions.

Sales / Retail:

  • Estimate product demand to avoid shortages or excess stock.
  • Plan inventory and promotions according to seasonality.

Public Health:

  • Track the progression of epidemics such as seasonal flu or COVID-19.
  • Forecast medical resource needs.

Weather / Energy:

  • Predict temperatures, rainfall, or electricity consumption.
  • Help companies and municipalities manage resources efficiently.

Transport / Logistics:

  • Forecast traffic or public transport passenger numbers.
  • Optimize schedules and resource allocation.

ARIMA **is not just theory—it’s a **practical tool to solve real problems across almost all sectors.

valuation / Results

At this stage, we haven’t applied the ARIMA model yet, but we can already draw important insights from visual exploration:

Identifying the trend:

  • The AirPassengers chart clearly shows a steady increase in passengers over the years.
  • Understanding this trend helps prepare future forecasts.

Identifying seasonality:

  • Every year, there are recurring summer peaks, typical of yearly seasonality.
  • Seasonality must be considered for accurate predictions.

Recognizing noise:

  • Unpredictable variations appear: some months deviate from the trend or seasonality.
  • ARIMA will later help correct past errors and reduce the impact of noise.

Exploratory analysis is the first crucial step in any time series modeling.
Before modeling with ARIMA, it’s essential to understand the series’ structure: trend, seasonality, and noise.

Conclusion and recap

In this introductory article, you’ve learned the basics to understand and explore time series:
What a time series is: data collected at regular intervals with trend, seasonality, and noise.

The intuition behind ARIMA:

  • AR (Auto-Regressive): memory of the past,
  • I (Integrated): series stabilization,
  • MA (Moving Average): error correction.

Python visualization: using the AirPassengers dataset to observe trend and seasonality.
Real-world use cases: finance, sales, health, weather, transport… ARIMA is everywhere forecasting is needed.
Exploratory evaluation: visualization already helps understand patterns and prepares for modeling.

This first step is crucial: understanding your data comes before modeling. The quality of your forecasts depends directly on this understanding.

Now that we’ve explored and understood the time series, it’s time to move to the next step: preparing data for ARIMA.

In the next article, we’ll cover:

  • how to check if a series is stationary,
  • how to apply **differencing **to make a series stationary,
  • which statistical tests to use: ADF (Augmented Dickey-Fuller) and KPSS,
  • and how to interpret these tests to decide the parameters of our ARIMA model.

This step is crucial: ARIMA works best on stationary series, and proper data preparation ensures more accurate forecasts.

See you in the next article to move from exploration to modeling!

Top comments (0)