# Linear Returns vs Log Returns to make a Forex time series stationary

I have a GBPUSD Forex time series. I am preparing the series as an input to LSTM. As a best practice for LSTM I am making the series stationary and I have tried both linear returns and log returns for this:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.tsa.stattools as ts

usecols=['Date','Close'])
df = df[df.index >= pd.to_datetime('2020-01-01')]
df['LinearReturns'] = df['Close'].pct_change() # Arithmetic Returns
df['LogReturns'] =  np.log(df['Close']/df['Close'].shift(1)) # Log Returns
df.dropna(how='any', inplace=True)

fig = plt.figure(figsize=(24, 18))
ax1, ax2, ax3, ax4, ax5 = fig.subplots(5)
ax1.set_title('Close')
ax1.set(xlabel='Date', ylabel='Close')
ax1.plot(df['Close'])
ax2.set_title('Linear Returns')
ax2.set(xlabel='Date', ylabel='Returns')
ax2.plot(df['LinearReturns'])
ax3.set_title('Linear Returns PDF')
ax3.hist(df['LinearReturns'], 159, range=[-0.0005, 0.0005])
ax3.plot()
ax4.set_title('Log Returns')
ax4.set(xlabel='Date', ylabel='Returns')
ax4.plot(df['LogReturns'])
ax5.set_title('Log Returns PDF')
ax5.hist(df['LogReturns'], 159, range=[-0.0005, 0.0005])
ax5.plot();



These are the results:

Linear Returns  (ADF, P-Value,...): (-53.67346634155517, 0.0, 79, 225629, {'1%': -3.4303789828630094, '5%': -2.8615528100499765, '10%': -2.5667768183276514}, -3188386.7366126943)
Log Returns (ADF, P-Value,...):     (-53.67104323432776, 0.0, 79, 225629, {'1%': -3.4303789828630094, '5%': -2.8615528100499765, '10%': -2.5667768183276514}, -3188345.3657192886)


Augmented Dickey-Fuller shows a P-Value of 0.0 for both returns, which is a proof of stationary characteristic.

It looks like the linear and the log returns have the same magnitude. my questions:

1. What is the difference in my case in using linear or log returns? Also, what is the difference in general and why would it matter?
2. I read somewhere that using the log is better for when you inverse the output of the LSTM as it will reduce the prediction exploding errors. Do you have an opinion on this?
3. Is there a better way of making this specific series (trending, no seasonality and some outliers) stationary?
• Because the series obviously is not stationary and hasn't become stationary through your operations, could you explain what you mean by "making" it stationary? – whuber Aug 12 '20 at 16:15
• @whuber I have added Augmented DF test to show that it is stationary. By making it stationary, I meant removing any trend. – Adam Aug 12 '20 at 22:47
• That's known as "first order stationary." In a stationary series, the distributions of the responses look the same at any time--and that's obviously not the case with your series, which grows visibly more variable about a third of the way through. – whuber Aug 13 '20 at 13:04
• @whuber The plotted returns can be realizations of a strictly stationary but conditionally heteroskedastic time series (which is reasonable in this particular case). – Michael Aug 13 '20 at 17:04
• @whuber I am not looking for strict stationarity as Michael mentioned – Adam Aug 13 '20 at 19:17

What is the difference in my case in using linear or log returns? Also, what is the difference in general and why would it matter?

The log returns and arithmetic returns would be close, trivially, if the returns are close to zero. FX returns for major currency pairs can be measured in basis points (percent of a percent)---empirically, this is very close to zero. (A 4 basis point move would be a huge move for this pair). As a result, the difference between these two quantities are negligible. This can be seen already in the time series and histogram plots you provide. (Incidentally, exchange rates between majors are also quoted in increments of 0.0001, except the yen.)

I read somewhere that using the log is better for when you inverse the output of the LSTM as it will reduce the prediction exploding errors. Do you have an opinion on this?

If the inputs series are close, one would expect the outputs to be also close.

Is there a better way of making this specific series (trending, no seasonality and some outliers) stationary?

For price series in general, computing returns is about the only standard thing to do if your method requires stationarity. Note that information regarding levels is lost when one computes the return series.

As a comment, FX series may not be the best playground for RNN-type methods. Those spikes in the return series are easily identifiable, and explained, by major economic events. Similarly, in a higher frequency exchange rate series with intra-day data, you would see clustering around the London 4pm fix, for example.

• thank you, what do you mean by 'levels'? You can reconstruct the time-series after the prediction (knowing the last price). – Adam Aug 14 '20 at 14:48
• @Adam Just the initial series of price/exchange rate levels. One wouldn't be able to address issues such as, for example, cointegration using the return/first-differenced series – Michael Aug 14 '20 at 20:00