Unlock Growth - Lock Savings
Offer Ends Soon

What Is ARIMA Model? And the overview of it

Image
What Is ARIMA Model? And the overview of it
In this blog, learn about what is ARIMA (Autoregressive integrated moving average) with examples, configuration and the merits & demerits of ARIMA.
Blog Author
Published on
Apr 6, 2023
Views
6730
Read Time
15 Mins
Table of Content

The ARIMA model is a useful tool for analyzing and forecasting various types of time series data, including financial and economic data, weather data, and traffic data. It is also widely used in industries such as retail, energy, and healthcare for demand forecasting, sales forecasting, and resource allocation. This blog explains the ARIMA model, and by the end of it, you will have a better understanding of ARIMA modelling and the importance of data science training to handle it effectively.

What Is ARIMA Modelling?

If the ARIMA model explained in simple terms, it is a statistical technique used to analyze time series data and make future predictions. It is commonly used to analyze data series such as stock prices, weather measurements, or economic indicators over time. The ARIMA model builds upon the Autoregressive Moving Average (ARMA) technique by considering the transformation of non-stationary time-series data into stationary data that does not show shifts in statistical characteristics over time. This transformation is achieved through a process known as differencing.

The ARIMA model consists of three key components: autoregressive (AR), differencing (I), and moving average (MA). The AR component takes into account the correlation between the current observation and past observations, while the MA component is based on the past prediction error term. By incorporating differencing, the model can achieve stability in data values.

Enroll in our Data Science Course in Bangalore to master analytics, tools, and operations, accelerating your career and earning an IBM certification.

Introduction to ARIMA

Two different methods for time series prediction are proposed: univariate and multivariate. In addition to the series of values, the univariate method uses only the previous values in the time series to predict future values. The multivariate method considers external variables as well to create the forecast.

This model has the capability of predicting a time series based on its past values. It can be applied to any time series that is not random or seasonal and exhibits patterns. In the example of a clothing store, the sales data is a time series since it was collected over a long period of time. One key characteristic of time series data is that it is collected over a regular and consistent period of time. We can modify it according to our needs and use it to predict sales for multiple seasons.

In cases with multiple seasons, the data must be corrected to account for seasonal differences in days because sales change according to the seasons. For instance, holidays fall on different days each year, creating a seasonal effect. The data should be adjusted by the data scientist to obtain an accurate prediction for upcoming sales.

ARIMA is a popular tool for forecasting future demands such as sales forecasts, stock prices, and manufacturing plans. The ARIMA model is becoming increasingly popular among data scientists.

Autoregressive Integrated Moving Average Model

An autoregressive integrated moving average (ARIMA) model is a widely used time series forecasting method that relies on past observations to predict future values. The model comprises three components: the autoregressive (AR) component, the integrated (I) component, and the moving average (MA) component.

The "AR" component predicts future values based on past values, using a variable that changes according to its own prior values.

"I" - This means that the goal is to achieve stationary data that does not vary with the seasons. This is done by measuring the difference between static data values and previous values. In other words, stationary data have statically constant properties over time, like mean, variance, and auto-correlation. Data scientists determine whether a data series is stationary by using the Augmented Dickey-Fuller (ADF) test.

Follow our blog for the latest trends and advancements in Time Series Forecasting methodologies.

"MA" - Moving averages are the result of applying a moving average model to previous observations and calculating an observed value based on the residual error.

As a result of the autoregressive part, the time series data is lagged in order to predict the current value of the time series. The order of the autoregressive part is represented by p, which represents the number of lagged values.

The integrated part of the model differentiates the time series so that they become stationary. Stationarity, as a statistical concept, indicates that the means and variance of the series remain constant over time. Differentiating time series to remove seasonality and trends is possible if the series is not stationary. The difference in the integrated part is represented by a "d", which represents the number of differentiations.

Moving averages are calculated by using past errors to predict the current value. The number of past errors used is indicated by “q”, which represents the number of moving averages. 

The ARIMA model is specified using the notation ARIMA(p, d, q) where the parts AR, I, and MA are specified in the order by the integers  "p", "d", and "q".

Maximal likelihood estimation is typically used to estimate the model, and the best model is chosen according to the Akaike information criterion (AIC) or the Bayesian information criterion (BIC).

The ARIMA model can provide useful insight into future trends and patterns in time series data and is widely used in finance, economics, and engineering applications. Several software tools can be used to build ARIMA models, including Python. Data scientists must confirm that the process they are modelling fits the ARIMA model before choosing the model. Using live data and training the model on a dataset, the data scientist constructs and plots a forecast if the dataset is an appropriate fit for the ARIMA model.

Shampoo Sales Dataset

The dataset, collected over a three-year period by data scientist Jason Brownlee, describes sales of shampoo in the United States. There were a total of 36 observations in the dataset. 

To make the dataset stationary, it must go through differencing. Here, the dataset is from actual sales instead of a simplified training set. There may be errors associated with seasonality. 

Data scientists can train their models with training datasets, then generate predictions using test datasets and compare them with training datasets. 

What Do p, d, and q Mean in ARIMA?

ARIMA stands for AutoRegressive Integrated Moving Average. It’s a time series forecasting model written as ARIMA(p, d, q), where each of the three numbers controls one part of the model.

Parameter Table

Parameter Component What it means How to choose it
p AutoRegressive (AR) The number of past values used to predict the current value. Look at the PACF (partial autocorrelation) plot, where the cutoff suggests p.
d Integrated (I) The number of times the data is differenced (each value minus the previous one) to remove trend and make it stationary. Use a stationarity test such as ADF, and increase d until the series is stationary. Usually 0, 1, or 2.
q Moving Average (MA) The number of past forecast errors used to predict the current value. ook at the ACF (autocorrelation) plot, where the cutoff suggests q.

In short: p is how much the model looks at its own past values, d is how much it smooths out the trend, and q is how much it learns from its past mistakes.

Simple Example

Suppose a shop’s monthly sales (in units) are:

100, 105, 111, 118, 126

Step 1: Handle the trend (d = 1). The values keep climbing, so the series isn’t stationary. Taking the difference between each month and the one before gives:

5, 6, 7, 8

These differences are stable enough to model, so d = 1.

Step 2: Use past values (p = 1). With p = 1, the model predicts the next difference from the most recent one. Say the model estimates:

next difference = 3 + 0.5 × (last difference)

The last difference is 8, so the next difference is 3 + 0.5 × 8 = 7.

Step 3: Convert back to sales. Add the predicted difference to the last actual value:

126 + 7 = 133 units forecast for next month.

Step 4: Add error correction (q). If q = 1, the model would also adjust that forecast slightly using last month’s forecast error. If last month’s prediction was too low, the model nudges the next forecast upward. The values 3 and 0.5 in the example are made up for illustration, since in practice software estimates them from the data.

So this model would be written as ARIMA(1, 1, 0), or ARIMA(1, 1, 1) with the error-correction term.

How Does the ARIMA Model Work?

ARIMA forecasts a time series by learning patterns from its own past values and past errors. The model follows a repeatable workflow, which is often called the Box-Jenkins method. Here are the steps in order.

1. Check Stationarity

ARIMA works best on a stationary series, meaning its mean, variance, and autocorrelation stay roughly constant over time. Trending or seasonal data usually isn’t stationary, which can make forecasts unreliable.

  • Plot the data and look for an obvious upward or downward trend or changing spread.

  • Run a statistical test, such as the Augmented Dickey-Fuller (ADF) test. A p-value below 0.05 generally suggests the series is stationary.

2. Difference the Data If Needed

If the series isn’t stationary, apply differencing: subtract each value from the one that follows it. This removes trend by modeling the changes instead of the raw levels.

  • One round of differencing (d = 1) fixes most trends.

  • If the series is still non-stationary, difference again (d = 2), though going beyond this is rare.

  • Re-run the stationarity test after each round. Avoid over-differencing, since it can add noise.

3. Select the Parameters (p, d, q)

With d settled, choose the other two values:

  • p (autoregressive order): use the PACF plot, where the lag at which it cuts off suggests p.

  • q (moving average order): use the ACF plot, where the lag at which it cuts off suggests q.

  • Compare candidates: try a few combinations and prefer the one with the lowest AIC or BIC, which balances accuracy against complexity.

Automated tools like auto_arima can search these combinations for you.

4. Fit the Model

Train the ARIMA(p, d, q) model on your historical data. The software estimates the coefficients, which are the weights applied to past values and past errors, usually through maximum likelihood estimation. It’s good practice to hold back the most recent portion of the data as a test set so you can evaluate forecasts later.

5. Check the Residuals

Residuals are the differences between the model’s predictions and the actual values. A good model captures the patterns in the data, leaving residuals that look like random noise.

  • Plot the residuals and confirm they fluctuate around zero with no visible pattern.

  • Check the ACF of the residuals, which should show no significant autocorrelation.

  • Run a Ljung-Box test, where a high p-value (above 0.05) suggests the residuals are uncorrelated.

If patterns remain, adjust p or q, or revisit differencing, then refit.

6. Forecast

Once the residuals look clean, use the model to predict future values. Forecasts are generated step by step, with each prediction building on earlier ones, and the model reverses the differencing so results appear on the original scale. Most tools also give confidence intervals, which widen further into the future to reflect growing uncertainty. Finally, compare forecasts against your held-out test data using metrics such as MAE, RMSE, or MAPE to see how well the model performs.

ARIMA Model Example

This example forecasts monthly product demand, a typical business use case. The data is simulated (generated with a fixed random seed so you can reproduce it), so treat the numbers as an illustration, not real sales. It covers 36 months of unit sales from January 2023 to December 2025. The model trains on the first 30 months, and the last 6 months are held back to test the forecast.

Step 1: Look at the Data

Demand climbs from about 100 units to 260 units over three years, with a steady upward trend. A trend like this usually means the series isn’t stationary.

Step 2: Test Stationarity and Difference

Series ADF p-value Conclusion
Raw sales 0.38 Not stationary (above 0.05)
After one difference 0.0045 Stationary (below 0.05)

One round of differencing fixes the trend, so d = 1.

Step 3: Choose p and q

I compared a grid of candidate models. The simple ARIMA(1, 1, 0) with a drift term was chosen, meaning the model uses last month’s change to predict this month’s change.

One caution: the lowest AIC actually went to ARIMA(2, 1, 2) at 165.2, against 171.3 for the chosen model. But its coefficients sat almost on the stability boundary (AR terms of about 1.91 and −0.99, MA terms of about −1.98 and 1.00), a sign of overfitting, and it forecast the held-out months far worse (about 8.9% error versus 1.5%). So the simpler model is the better choice here. Don’t pick on AIC alone.

Step 4: Fit the Model

python

import numpy as np, pandas as pd

from statsmodels.tsa.stattools import adfuller

from statsmodels.tsa.arima.model import ARIMA

from statsmodels.stats.diagnostic import acorr_ljungbox

 

# Simulated monthly demand (36 months, reproducible)

rng = np.random.default_rng(100)

n = 36

d = np.zeros(n); level = np.zeros(n); level[0] = 100

for t in range(1, n):

    d[t] = 4 + 0.5 * (d[t-1] - 4) + rng.normal(0, 4)

    level[t] = level[t-1] + d[t]

sales = pd.Series(level.round(0),

                  index=pd.date_range("2023-01-01", periods=n, freq="MS"))

 

train, test = sales[:30], sales[30:]

 

print(adfuller(train)[1])                      # stationarity check (raw)

print(adfuller(train.diff().dropna())[1])      # after differencing

 

model = ARIMA(train, order=(1, 1, 0), trend="t").fit()

print(model.summary())

 

print(acorr_ljungbox(model.resid[1:], lags=[8]))   # residual check

 

forecast = model.get_forecast(steps=6)

print(forecast.predicted_mean)

print(forecast.conf_int())

The setting trend="t" adds a drift term, which lets the forecast keep rising with the trend instead of flattening out.

Fitted values: drift ≈ 4.4 units per month, AR(1) coefficient ≈ 0.59.

Step 5: Check the Residuals

The Ljung-Box test gives a p-value of 0.88, well above 0.05, so the residuals look like random noise and no obvious pattern is left unexplained.

Month Forecast Actual 95% interval
Jul 2025 241.3 241 233.2 – 249.5
Aug 2025 246.3 246 231.0 – 261.6
Sep 2025 251.0 246 229.0 – 273.1
Oct 2025 255.6 249 227.5 – 283.8
Nov 2025 260.2 254 226.4 – 293.9
Dec 2025 264.6 260 225.8 – 303.4

Accuracy: MAE ≈ 3.8 units and MAPE ≈ 1.5%. Every actual value falls inside its 95% interval.

How to Read the Results

  • The forecast tracks the trend well, but it drifts slightly high in the later months, since the actual series slowed a little.

  • The intervals widen with time (about 16 units wide in month one versus about 78 in month six), which shows uncertainty growing the further ahead you forecast.

  • For planning, refitting on all 36 months gives a forecast of roughly 265, 270, and 275 units for January to March 2026.

Using It for Real Demand Data

Replace the simulated series with your own monthly sales, then follow the same workflow: test stationarity, difference, compare candidate models on held-out data, check residuals, and forecast. If your data shows a repeating seasonal pattern, such as holiday peaks, use SARIMA instead, since plain ARIMA doesn’t model seasonality.

How to Choose ARIMA Model Parameters

Choosing (p, d, q) comes down to three tools: stationarity checks for d, the PACF plot for p, and the ACF plot for q. AIC and BIC then help you pick between the candidates.

Step 1: Choose d (Differencing)

  • Plot the series and run the ADF test. A p-value below 0.05 suggests the series is stationary.

  • If it isn’t, difference once (d = 1) and test again. Most series need d = 0 or 1.

  • Rarely go to d = 2, and avoid over-differencing, since it adds noise.

Step 2: Understand ACF and PACF

ACF (Autocorrelation Function)

  • Shows the correlation between the series and its own lagged values (lag 1, lag 2, and so on).

  • Includes indirect effects, since lag 1’s influence passes through to lag 2.

  • Used to pick q (moving average order).

PACF (Partial Autocorrelation Function)

  • Shows the correlation at each lag after removing the effect of the shorter lags in between.

  • Isolates the direct effect of each lag.

  • Used to pick p (autoregressive order).

Always plot ACF and PACF on the differenced (stationary) series.

Pattern Suggested model
PACF cuts off after lag p; ACF tails off gradually AR(p), so set p
ACF cuts off after lag q; PACF tails off gradually MA(q), so set q
Both tail off gradually ARMA/ARIMA with both p and q, where you’ll need to test combinations
  • “Cuts off” means the bars drop inside the confidence band after a given lag.

  • Count the last significant lag before the drop. That lag number is your starting p or q.

Step 4: Compare Candidates With AIC and BIC

AIC (Akaike Information Criterion)

  • Measures model fit while penalizing complexity (the number of parameters).

  • Lower is better.

  • Tends to favor slightly larger models and suits forecasting.

BIC (Bayesian Information Criterion)

  • Works like AIC but applies a heavier penalty for extra parameters, especially with larger samples.

  • Lower is better.

  • Tends to pick simpler models.

ARIMA vs. SARIMA: What Is the Difference?

ARIMA models trend and short-term patterns in a series. SARIMA (Seasonal ARIMA) adds a second set of terms that capture patterns repeating at a fixed interval, such as every 12 months. If your data has a regular seasonal cycle, plain ARIMA will miss it.

Aspect ARIMA SARIMA
Full name AutoRegressive Integrated Moving Average Seasonal AutoRegressive Integrated Moving Average
Notation ARIMA(p, d, q) SARIMA(p, d, q)(P, D, Q)m
Parameters 3: p (AR order), d (differencing), q (MA order) 7: the same three, plus P, D, Q (seasonal versions) and m (season length)
Handles trend Yes, through differencing (d) Yes, through differencing (d)
Handles seasonality No Yes, through seasonal terms (P, D, Q) and seasonal differencing (D)
Seasonal period (m) Not used Required, for example 12 for monthly data with a yearly cycle, 4 for quarterly, 7 for daily data with a weekly cycle
Typical data Trending data with no repeating cycle Data with regular peaks and dips, such as holiday sales or summer energy demand
Complexity Simpler and faster to fit More parameters, slower to fit, and harder to tune
Data needed Moderate history More history, ideally at least 2 to 3 full seasonal cycles
Risk if misused Forecasts ignore seasonal swings and miss peaks Overfitting or unstable fits if there’s no real seasonality or too little data

When Seasonality Needs Consideration

Consider SARIMA when you see any of these signs:

  • Repeating peaks and troughs at regular intervals in the plot, such as sales spiking every December or electricity demand rising every summer.

  • ACF spikes at seasonal lags, for example strong autocorrelation at lags 12, 24, and 36 for monthly data.

  • A clear seasonal component in a decomposition (STL or classical decomposition), with a pattern that repeats at a consistent size.

  • Residuals from a plain ARIMA that still show repeating patterns or significant seasonal ACF spikes.

  • Business context that makes it obvious, such as retail holidays, school terms, tourism seasons, weather-driven demand, or weekly cycles in web traffic.

Rolling Forecast ARIMA Model

Rolling forecasts are used to compare time series models. Typically, rolling forecasts are updated every day based on the previous day’s sales data. It is possible to determine if the data series is stationary by plotting the rolling mean and standard deviation, and also to determine if it is not stationary by using the ADF test. When a new data point is collected, a rolling forecast ARIMA model is updated with the new data and generates the forecast for the next time period.

A rolling forecast ARIMA model is particularly useful for time series data that are non-stationary and may evolve over time. The steps to implement a rolling forecast ARIMA model are as follows:

  1. Load the data: Time series data should be loaded into a Pandas data frame.
  2. Define the training and testing sets: To fit the ARIMA model, split the data into training and testing sets, and then evaluate the model’s performance on the testing set.
  3. Define the ARIMA model: A training set’s autocorrelation and partial autocorrelation plots can be used to determine the order of the ARIMA model.
  4. Fit the ARIMA model: The training set should be fitted with an ARIMA model.
  5. Generate the forecast: Calculate the forecast for the next time step using the fitted ARIMA model. 
  6. Update the model: Fit the ARIMA model on the updated training set after adding the actual value of the next time step and removing the oldest value. 
  7. Repeat steps 5 and 6 for each new time step in the testing set.
  8. Evaluate the model: Evaluation of a model’s performance requires calculating error metrics, such as mean squared error (MSE), root mean squared error (RMSE), and mean absolute error (MAE).

Configuring an ARIMA Model

Experts recommend a dataset with a minimum of 50 observations, preferably 100. This is the first step when applying the ARIMA model to data.

 Here are the other general steps to configure an ARIMA model:

  1. Stationarity Check: You can test the stationarity of the time series by plotting the series, calculating summary statistics, and conducting statistical tests. ARIMA assumes that the data series is stationary, which means that the statistical properties remain the same over time.
  2. Differencing: Using the diff() function in R or the diff() method in Stata will enable you to apply differencing to a time series that is not stationary. The order of differencing (d) determines how many times you need to apply differencing to achieve stationarity.
  3. ACF and PACF Plots: To determine the order of autoregression (p) and moving average (q) after differences, you can use autocorrelation functions (ACFs) or partial autocorrelation functions (PACFs). PACF plots indicate a correlation between lagged values and time series after removing the effects of intermediate lags, whereas ACF plots show a correlation after removing the effects of intermediate lags.
  4. Model Selection: As a result of comparing the ACF and PACF plots, you can identify possible combinations of p and q, and then create several candidate models to evaluate their performance using criteria such as Akaike Information Criterion (AIC) and Bayesian Information Criterion (BIC). The model with the lowest AIC or BIC value is considered the best model.
  5. Model Validation: When you have chosen the best model, you should evaluate its performance using hold-out data. You can compare the forecasted values with the actual values and calculate evaluation metrics including Mean Absolute Error (MAE), Root Mean Square Error (RMSE), and Maximum Amount Percentage Error (MAPE).
  6. Model Refinement: In case the model does not perform satisfactorily, you can refine it with smaller values for p, q, and d, or you can incorporate other variables. In order to choose the optimum model for a particular time series dataset, constructing an ARIMA model generally entails a combination of statistical analysis, visualisation, and experimentation.

Two types of errors are common during the validation or diagnostic stages: overfitting and residual errors. The presence of overfitting indicates that the model is more complex than necessary and that it has been influenced by random noise in the dataset. Having residual errors can alert you to bias in your forecasting model, which may cause inaccurate forecasting.

Merits and demerits of ARIMA model

Merits

  • These are flexible and have the capability to adapt to any wide range of data whether linear or nonlinear rendering the data useful to analyze real-world phenomena.
  • You can use it to predict the future values of time series.
  • These are widely used because of the resources available and considering the fact that it is easy to implement and interpret.
  • The results are also reliable because of the methods used, i.e statistical methods and theory.

Demerits

  • Sometimes the real case scenario may change because the ARIMA model assumes stationary data and for long-term prediction, the accuracy may fall as the forecast horizon increases.
  • ARIMA models' accuracy is limited by the amount of data available, and they can be complex and hard to interpret, especially for non-experts.

Now, all of these concerns can be rectified if the model is handled properly. The Data Science course from StarAgile may be perfect for this task.

 
 
 
 
Get Our Data Science Course Now

Also Read: Data Science For Retail

Summary

The ARIMA model is a crucial idea in data science and a potent tool for time series analysis and forecasting. Data scientists can set up an ARIMA model to give important insights into trends, seasonality, and other patterns in time series data by following an organised process of identification, estimation, and validation. Consider enrolling in a StarAgile data science training if you're interested in learning more about data science and mastering methods like the ARIMA model. You can develop the abilities and knowledge required to succeed in a data-driven environment by receiving in-depth instruction and practical experience. Not only that, securing Data science certification will help you to get better opportunities than the non certified individuals. Take advantage of this chance to advance your career by enrolling in a StarAgile data science course right away

About Author
Akshat Gupta

Founder of Apicle technology private limited

founder of Apicle technology pvt ltd. corporate trainer with expertise in DevOps, AWS, GCP, Azure, and Python. With over 12+ years of experience in the industry. He had the opportunity to work with a wide range of clients, from small startups to large corporations, and have a proven track record of delivering impactful and engaging training sessions.

Are you Confused? Let us assist you.
+1
Explore Data Science Course!
Upon course completion, you'll earn a certification and expertise.
Image Image Image Image

Trending Articles

The most effective project-based immersive learning experience to educate that combines hands-on projects with deep, engaging learning.
WhatsApp