Modified Rescaled Range Test
The Modified Rescaled Range Test of Lo (1991) is a test of long memory based on the rescaled range (R/S) of Hurst and Mandelbrot: the range of the cumulative deviations from the mean, divided by a standard deviation. The classical rescaled range also reacts to short-run autocorrelation, so it finds long memory where there is none. Lo replaced the standard deviation by a long-run standard deviation that absorbs the short-run autocorrelation, so that only long memory moves the statistic.
The formula for the Modified Rescaled Range Test starts from the partial sums \(S_{k}\) of the deviations of the series from its mean and their range:
\[S_{k} = \sum_{j=1}^{k} (x_{j} - \bar{x})\]It divides that range by the Newey-West long-run standard deviation hat(sigma_q), with q lags and the autocovariances hat(gamma_j):
\[\hat{\sigma}_{q}^{2} = \hat{\gamma}_{0} + 2 \cdot \sum_{j=1}^{q} \left(1 - \frac{j}{q + 1}\right) \cdot \hat{\gamma}_{j}\] \[V = \frac{\max\left(S_{k}\right) - \min\left(S_{k}\right)}{\hat{\sigma}_{q} \cdot \sqrt{n}}\]The number of lags q follows Andrews (1991) from the first autocorrelation hat(rho) of the series:
\[q = \left\lfloor \left(\frac{3 \cdot n}{2}\right)^{1/3} \cdot \left(\frac{2 \cdot \left\lvert \hat{\rho}\right\rvert}{1 - \hat{\rho}^{2}}\right)^{2/3}\right\rfloor\]Without long memory V follows the range of a Brownian bridge, with distribution function F, and the p-value is two-sided:
\[F(v) = 1 + 2 \cdot \sum_{k=1}^{\infty} \left(1 - 4 \cdot k^{2} \cdot v^{2}\right) \cdot \exp\left(-2 \cdot k^{2} \cdot v^{2}\right)\] \[\text{P Value} = 2 \cdot \min\left(F(V), 1 - F(V)\right)\]Where \(x_{j}\) is the series, bar(x) its mean, n the number of observations, the maximum and minimum run over k, and hat(gamma_j) are the autocovariances with n in the denominator. The short memory null is rejected when the p-value is below the significance level (0.05 for the 5% level), which at 5% is when V lies below 0.809 or above 1.862 (Lo, 1991); a large V points to persistence, a small one to anti-persistence. The correction for short-run autocorrelation costs power: the more lags q, the harder it is to detect long memory.
A series has long memory when its shocks fade so slowly that its autocorrelations decay hyperbolically, like \(k^{2 d - 1}\) at lag k, instead of exponentially as for an ARMA process. Such a series is fractionally integrated with a memory parameter d: differencing it d times, a fraction, leaves short memory. \(d = 0\) is short memory, \(0 < d < 0.5\) long memory that is still stationary (persistent), \(- 0.5 < d < 0\) anti-persistence, d from 0.5 up to 1 a non-stationary but mean-reverting series and \(d = 1\) a unit root. A long memory test asks whether d differs from 0: the null hypothesis is short memory, the alternative long memory or anti-persistence. Returns of liquid assets usually show d close to 0, while their absolute or squared returns (volatility) and many macroeconomic series such as inflation show d clearly above 0. The Hurst exponent of the series is d + 0.5, and the fractional difference removes the memory once d is known.
Also known as: Lo’s modified R/S, modified R/S test, Lo test.
In the Finance Toolkit this is get_long_memory_test with method="modified_rescaled_range", the same function as Long Memory Test.
Example · AAPL, MSFT · 2016 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_long_memory_test:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2016-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_long_memory_test(method="modified_rescaled_range")
| Parameter | Type | Description | Example |
|---|---|---|---|
method | str | The test. Options are: “gph” (Geweke-Porter-Hudak Estimator, a log periodogram regression), “local_whittle” (Local Whittle Estimator), “modified_rescaled_range” (Modified Rescaled Range Test, Lo’s modified R/S). Defaults to “gph”. | "gph" |
period | str | The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
column | str | The historical data column. Defaults to “Return”. | "Return" |
power | float | The bandwidth \(m = \text{⌊} n^{\text{power}} \text{⌋}\) of the GPH and local Whittle tests, between 0 and 1: a larger power uses more frequencies, which lowers the standard error but lets short memory bias d. Defaults to 0.5. | 2 |
lags | int | None | The lags q of the modified rescaled range. Defaults to None, which takes Andrews’ (1991) choice. | 2 |
include_benchmark | bool | Whether to include “Benchmark” among the assets. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
Which returns:
| Item | AAPL | MSFT |
|---|---|---|
| Statistic | 1.1276 | 1.1279 |
| P-Value | 0.7118 | 0.7126 |
| Lags | 3.0000 | 7.0000 |
| Observations | 2,513.0000 | 2,513.0000 |
4 rows
Using Your Own Data
get_long_memory_test runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:
from financetoolkit import Economics, Econometrics
economics = Economics(start_date="2000-01-01")
unemployment = economics.get_unemployment_rate(
countries=["United States", "Germany"], period="monthly"
)
econometrics = Econometrics(data=unemployment, changes="difference")
econometrics.get_long_memory_test()
References
- Paper Lo, A.W. (1991). “Long-Term Memory in Stock Market Prices.” Econometrica, 59(5), 1279-1313.
- Paper Andrews, D.W.K. (1991). “Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation.” Econometrica, 59(3), 817-858.