RURTEST
This function applies the Range Unit-Root (RUR) test, which tests a stationarity null hypothesis using a range-based statistic.
It is designed as an alternative unit-root diagnostic that can be robust under nonlinearities and structural features considered in its original development.
The output includes the RUR statistic, p-value, and critical values used for interpretation.
Excel Usage
=RURTEST(x, store)
x(list[list], required): Time-series observations as a 2D range.store(bool, optional, default: false): Return result storage object in addition to scalar outputs.
Returns (list[list]): 2D key-value table summarizing RUR test outputs.
Example 1: Range unit-root test on mildly trending data
Inputs:
| x | store | |||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1.05 | 1.02 | 1.08 | 1.06 | 1.1 | 1.09 | 1.12 | 1.1 | 1.14 | 1.16 | 1.18 | 1.2 | 1.19 | 1.22 | 1.24 | 1.23 | 1.27 | 1.29 | 1.31 | 1.3 | 1.33 | 1.36 | 1.35 | 1.38 | 1.4 | 1.42 | 1.41 | 1.44 | 1.46 | false |
Excel formula:
=RURTEST({1,1.05,1.02,1.08,1.06,1.1,1.09,1.12,1.1,1.14,1.16,1.18,1.2,1.19,1.22,1.24,1.23,1.27,1.29,1.31,1.3,1.33,1.36,1.35,1.38,1.4,1.42,1.41,1.44,1.46}, FALSE)
Expected output:
| Result | |
|---|---|
| rur_stat | 3.65148 |
| p_value | 0.95 |
| critical_10% | 1.09624 |
| critical_5% | 0.94492 |
| critical_2.5% | 0.83556 |
| critical_1% | 0.68962 |
Example 2: Range unit-root test on level-stationary-looking data
Inputs:
| x | store | |||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5 | 5.02 | 4.99 | 5.01 | 5 | 5.03 | 4.98 | 5.01 | 5 | 5.02 | 4.99 | 5.01 | 5 | 5.03 | 4.97 | 5 | 5.01 | 4.99 | 5.02 | 5 | 4.98 | 5.01 | 5 | 5.02 | 4.99 | 5.01 | 5 | 5.03 | 4.98 | 5 | false |
Excel formula:
=RURTEST({5,5.02,4.99,5.01,5,5.03,4.98,5.01,5,5.02,4.99,5.01,5,5.03,4.97,5,5.01,4.99,5.02,5,4.98,5.01,5,5.02,4.99,5.01,5,5.03,4.98,5}, FALSE)
Expected output:
| Result | |
|---|---|
| rur_stat | 0.912871 |
| p_value | 0.05 |
| critical_10% | 1.09624 |
| critical_5% | 0.94492 |
| critical_2.5% | 0.83556 |
| critical_1% | 0.68962 |
Example 3: Range unit-root test on higher variance observations
Inputs:
| x | store | |||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 | 2.4 | 2.1 | 2.5 | 2.2 | 2.6 | 2.3 | 2.7 | 2.4 | 2.8 | 2.35 | 2.9 | 2.45 | 2.95 | 2.5 | 3 | 2.55 | 3.05 | 2.6 | 3.1 | 2.65 | 3.15 | 2.7 | 3.2 | 2.75 | 3.25 | 2.8 | 3.3 | 2.85 | 3.35 | false |
Excel formula:
=RURTEST({2,2.4,2.1,2.5,2.2,2.6,2.3,2.7,2.4,2.8,2.35,2.9,2.45,2.95,2.5,3,2.55,3.05,2.6,3.1,2.65,3.15,2.7,3.2,2.75,3.25,2.8,3.3,2.85,3.35}, FALSE)
Expected output:
| Result | |
|---|---|
| rur_stat | 2.73861 |
| p_value | 0.95 |
| critical_10% | 1.09624 |
| critical_5% | 0.94492 |
| critical_2.5% | 0.83556 |
| critical_1% | 0.68962 |
Example 4: Range unit-root test on smooth growth sequence
Inputs:
| x | store | |||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 3 | 3.05 | 3.1 | 3.16 | 3.2 | 3.25 | 3.31 | 3.36 | 3.4 | 3.45 | 3.5 | 3.55 | 3.6 | 3.66 | 3.7 | 3.75 | 3.81 | 3.86 | 3.9 | 3.95 | 4 | 4.05 | 4.1 | 4.16 | 4.2 | 4.25 | 4.31 | 4.36 | 4.4 | 4.45 | false |
Excel formula:
=RURTEST({3,3.05,3.1,3.16,3.2,3.25,3.31,3.36,3.4,3.45,3.5,3.55,3.6,3.66,3.7,3.75,3.81,3.86,3.9,3.95,4,4.05,4.1,4.16,4.2,4.25,4.31,4.36,4.4,4.45}, FALSE)
Expected output:
| Result | |
|---|---|
| rur_stat | 5.29465 |
| p_value | 0.95 |
| critical_10% | 1.09624 |
| critical_5% | 0.94492 |
| critical_2.5% | 0.83556 |
| critical_1% | 0.68962 |
Python Code
import numpy as np
from statsmodels.tsa.stattools import range_unit_root_test as sm_range_unit_root_test
def rurtest(x, store=False):
"""
Run the range unit-root test as an alternative stationarity diagnostic.
See: https://www.statsmodels.org/stable/generated/statsmodels.tsa.stattools.range_unit_root_test.html
This example function is provided as-is without any representation of accuracy.
Args:
x (list[list]): Time-series observations as a 2D range.
store (bool, optional): Return result storage object in addition to scalar outputs. Default is False.
Returns:
list[list]: 2D key-value table summarizing RUR test outputs.
"""
try:
def to1d(values):
if isinstance(values, list):
if all(isinstance(row, list) for row in values):
raw = [item for row in values for item in row]
else:
raw = values
else:
raw = [values]
out = []
for item in raw:
try:
out.append(float(item))
except (TypeError, ValueError):
continue
return out
series = to1d(x)
if len(series) < 25:
return "Error: x must contain at least 25 numeric values"
result = sm_range_unit_root_test(np.asarray(series, dtype=float), store=store)
rur_stat = float(result[0])
p_value = float(result[1])
crit_values = result[2]
rows = [
["rur_stat", rur_stat],
["p_value", p_value],
]
if isinstance(crit_values, dict):
for key in ("10%", "5%", "2.5%", "1%"):
if key in crit_values:
rows.append([f"critical_{key}", float(crit_values[key])])
return rows
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Time-series observations as a 2D range.
Return result storage object in addition to scalar outputs.