Data ScienceForecasting and time-series analysis

Stationarity: what differencing changes and what it loses

PK
Pankit Kumar
Sr. Data Scientist at Parexel (a Goldman Sachs–backed company) · 20 September 2026 · 2 min read
Technically reviewed by Ishaan Sharma
In this article (5 sections)

Many time-series models assume that relevant statistical behavior is stable over time. Differencing is one way to remove a changing level: replace each observation with the change from the previous observation. It can make a trending series easier to model, but it changes the target and discards a boundary value. It should be treated as a transformation with a reversible contract, not a checkbox labeled “make stationary.”

For observations y[t], the first difference is d[t] = y[t] - y[t-1]. Forecasts made in differences must be accumulated from the last known level to return to the original unit.

What changed in the lab

The time-series lab differences 120 pre-break monthly observations.

DiagnosticOriginalFirst difference
Mean72.540.34
Lag-1 correlation0.882-0.216

The lower lag correlation shows that differencing changed dependence in this fixture. It does not by itself prove stationarity. A formal test also depends on its null hypothesis, deterministic terms, lag settings and sample size; structural breaks can mislead it.

python
from timeseries_cases import difference_case

result = difference_case()
assert result["max_reconstruction_error_with_initial_level"] < 1e-10
print(round(result["original_lag1_correlation"], 3))
print(round(result["difference_lag1_correlation"], 3))

The reconstruction error is about 1.4e-14 because the initial level is retained. Without that first value, the differenced sequence contains changes but cannot recover the absolute series.

Differencing can create problems

Over-differencing can inject negative autocorrelation and amplify noise. It can also remove a trend that a business stakeholder wants to interpret directly. Seasonal differencing, such as y[t] - y[t-12] for monthly annual recurrence, makes a different assumption from first differencing. Applying both consumes more early observations and changes the forecast integration step.

Plot the level and differences, inspect autocorrelation, and compare models through chronological validation. Record the number and type of differences as part of the model artifact. If missing periods exist, establish a complete calendar before differencing; adjacent stored rows may not represent adjacent months.

Preserve the forecast unit

Stakeholders need demand in units, not an unexplained monthly change. Store the last observed level at each origin, invert transformations for every horizon, and score the reconstructed forecast against original-scale actuals. Intervals also need to be transformed coherently because uncertainty accumulates across horizons.

The example uses a known synthetic trend so the transformation can be checked exactly. On real data, an analyst should not infer the generator or promise that a differenced process will remain stable. Regime changes, changing variance and calendar effects need separate treatment.

The Data Science course links transformations to ARIMA specification, diagnostics and backtesting so learners can explain what the model consumes and what the business receives.

Exercise

Compare first differencing, seasonal differencing at lag 12, and both together. For each pipeline, state the lost rows, values required for inversion and validation RMSE after reconstruction. Reject transformations using validation rather than visual smoothness alone.

Continue learning

This article is part of the Forecasting and time-series analysis sequence. Use the neighbouring tasks when you need the prerequisite or the next application.

Reference: Forecasting: Principles and Practice on stationarity and differencing.

PK
Pankit Kumar
Lead Instructor, NeuraPath Academy

Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.

This article is part of our Data Science programme — 6 months. From data foundations to machine learning, deep learning and deployment.

Explore Data Science
Counselling is free · no obligation

Not sure which programme fits?

Tell us your background and we will map it to the right entry point — including saying so when a cheaper programme is the better fit. A counsellor replies within one working day.