- Published on
Fractional Differentiation
Fractional Differentiation
This chapter introduces fractional differentiation as a method to solve the "Stationarity vs. Memory Dilemma." This is the core problem where standard data transformations create a conflict:
- Prices (
d=0) have memory (predictive power) but are non-stationary. - Returns (
d=1) are stationary but are memory-less.
ML models need stationarity, but they also need memory to have predictive power. The standard practice of using returns (d=1) often "over-differentiates" the data, wiping out valuable memory and reinforcing the efficient market hypothesis.
Fractional differentiation finds the minimum amount of differentiation (where is a real number, e.g., ) required to make a series stationary, thereby preserving the maximum possible memory.
The Method
The method generalizes the integer differencing operator to allow to be any real number. This is based on the binomial series expansion of the backshift operator :
A fractionally differentiated series is the dot product of the original series and a set of weights :
When is an integer (like 1), the weights become for , cutting off all memory. When is a non-integer, the weights converge to zero but never become exactly zero, thus preserving memory.
The weights can be calculated iteratively (with ):


Implementation
The chapter compares two implementation methods:
Expanding Window (Standard Method): This method uses an increasing number of data points to compute the weights for each subsequent observation. This is flawed as it causes a negative drift in the transformed series.
Fixed-Width Window Fracdiff (FFD): This is the author's preferred method.
- It first determines a fixed number of weights by finding where the weight modulus falls below a given tolerance threshold .
- This same fixed set of weights is then applied to all observations.
- This method avoids the negative drift and produces a stationary series that retains memory.
Finding the Optimal
The primary goal is to find the minimum differentiation that makes a series stationary. This is achieved by:
- Generating multiple FFD series for values in the range .
- Running an Augmented Dickey-Fuller (ADF) test on each series.
- Identifying the minimum where the ADF statistic falls below the 95% confidence level critical value.
An example on E-mini S&P 500 futures shows that while the ADF critical value is -2.86, the original series is -0.33 (non-stationary) and the returns series (d=1) is -46.91 (hyper-stationary). The series becomes stationary at , while still retaining a 0.995 correlation with the original series. In contrast, returns (d=1) only have a 0.03 correlation, showing that all memory was destroyed.
The conclusion is that most financial analysis is over-differentiated, and FFD provides a "third way" to get stationary, memory-filled data for ML models.

Implementation: Fractional Differentiation
In RiskLabAI, we implement fractional differentiation in the data.differentiation.differentiation module. This technique allows us to make a time series stationary while preserving memory, which is crucial for financial machine learning models.
We provide two main methods for differentiation:
- Standard (Expanding Window): This method uses all available history for each data point. It is more memory-intensive but used for finding the optimal 'd'.
- Fixed-Width Window (FFD): This is the preferred method for feature generation. It uses a fixed window determined by a weight threshold, making it faster and preventing the series from fading to zero. We provide a highly optimized version using
np.convolve.
Finding the Optimal 'd'
We also provide utility functions to find the minimum differentiation factor d that results in a stationary series (as determined by the ADF test).
The fractionally_differentiated_log_price function is particularly useful, as it iterates d from 0 upwards by step until the ADF test p-value drops below the p_value_threshold, returning the stationary series.
API reference
RiskLabAI implements these in Python and Julia (signatures auto-generated from the package source):
| Python | Julia |
|---|---|
| |
| |
| |
| |
| |
| |