Skip to content
All library documents

Log Differences as Approximate Returns for Financial Time Series

Article Quant Q&A · Author: SkyWalker

Summary

The document asks what happens when a financial price series is logged and then differenced, using an S&P 500 closing-price series as an example. It describes the common feature-engineering step of taking the change between consecutive log prices and relates ordinary first differences to a discrete approximation of change over time.

It suggests that logging can turn multiplicative components into additive ones and that differencing may reduce the effect of slowly changing trend or seasonal components. The resulting value is often interpreted as a log return, approximately a percentage price change for small moves, and can serve as a model predictor. However, the document does not provide empirical tests or resolve its own question fully. Its decomposition is imprecise: differencing a log series does not generally isolate a residual, and logging does not automatically remove heteroscedasticity. The usefulness of the feature depends on the data and modeling context.

Key ideas

  • A log difference is the change in log price from one observation to the next.
  • For small price changes, a log difference approximates a simple percentage return.
  • Logging can express multiplicative components additively when the series follows a suitable multiplicative decomposition.
  • Differencing may reduce slowly varying level effects, but it does not generally isolate a residual component.
  • A log-difference feature can be used as a predictor, though its value requires empirical assessment.

Tags

Full text
# Disecting a log diff transformation for time series analysis and prediction


# Disecting a log diff transformation for time series analysis and prediction












I have been working in a predictive ML model that uses financial time-series as predictor variables. In one of the academic papers I used as reference, and to do feature engineering for building the predictors they recommended doing a log diff transformation of the price.

In Python:

```
import pandas as pd
import numpy as np
import yfinance as yf

# download the S&P500 
df = yf.download('^GSPC')
df['Close_log_diff'] = np.log(df['Close']).diff()
```

it turned out to be useful as predictor but I'm a bit confused as what's happening.

A first order difference would correspond to an approximation of the first derivative:

$\text{m}_t = \frac{f(x_{t}) - f(x_{t-1})}{x_{t} - x_{t-1}}\ \text{where}\ (x_{t} - x_{t-1})=1$

However, doing that after a log transformation is a bit trickier. The log would remove the heteroscedasticity or any multiplicative effect between the trend and seasonal components in a time-series with trend, seasonal and residual or error term.

If the original series is:

$x_t = m_t \dot\ s_t + z_t$

Then the log series becomes:

$\text{log}(x_t) = m_t + s_t + z_t'$

If I now apply a first order differencing I get the following:

$m_t + s_t + z_t' - m_{t-1} - s_{t-1} - z_{t-1}'$

Because the trend and seasonal components should be fairly close between $x_t$ and $x_{t-1}$, then my log diff essentially is:

$z_t' - z_{t-1}'$

What does this mean?

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.