Wright Rank Test
The Wright Rank Test (R1) of Wright (2000) is the variance ratio test on the ranks of the returns instead of the returns themselves. The Lo-MacKinlay Variance Ratio Test relies on a normal approximation that can be poor in small samples and with fat tails. Under independence every ordering of the ranks is equally likely, so the distribution of the statistic is known exactly in any sample, and a few extreme returns cannot dominate it.
The formula for the Wright Rank Test first replaces each of the n returns \(r_{t}\) by its rank among them, Rank(r_t), from 1 for the smallest to n for the largest, and standardizes the ranks to a mean of 0 and a variance of 1:
\[x_{t} = \frac{\text{Rank}(r_{t}) - \frac{n + 1}{2}}{\sqrt{\frac{(n - 1) \cdot (n + 1)}{12}}}\]The statistic \(R_{1}\) is the variance ratio of these standardized ranks: the variance of the sums of q consecutive values over q times the variance of a single value, minus 1 and divided by its standard deviation sqrt(phi(q)):
\[R_{1} = \frac{\frac{\frac{\sum_{t=q}^{n} \sum_{j=0}^{q - 1} x_{t-j}^{2}}{n \cdot q}}{\frac{\sum_{t=1}^{n} x_{t}^{2}}{n}} - 1}{\sqrt{\phi(q)}}\] \[\phi(q) = \frac{2 \cdot (2 \cdot q - 1) \cdot (q - 1)}{3 \cdot q \cdot n}\]The variance ratio of the ranks is \(1 + R_{1} \cdot \sqrt{\phi (q)}\). The p-value is two-sided and comes from the exact distribution of \(R_{1}\) under independence, simulated by ordering the ranks at random. A positive statistic with a p-value below the significance level points to momentum, a negative one to mean reversion. The ranks keep the order of the returns but not their size, so the test is exact only for independent returns with a constant distribution: volatility clustering on its own can lead it to reject.
A variance ratio test asks whether prices follow a random walk: if returns are uncorrelated, the variance of returns over q periods is q times the variance of single-period returns, and their ratio is 1. The null hypothesis is that random walk, the alternative that returns are autocorrelated over the horizon. A ratio above 1 means that moves tend to continue (momentum, trending), a ratio below 1 that they tend to reverse (mean reversion). The ratio sums up the autocorrelations of all lags up to q in one number, which makes it more powerful against slow, persistent patterns than a test of a single autocorrelation. A p-value below the chosen significance level (such as 0.05) rejects the random walk; a higher p-value means the returns are consistent with it at that horizon.
Also known as: R1 test, Wright’s rank test, rank variance ratio test.
In the Finance Toolkit this is get_variance_ratio_test with method="wright_rank", the same function as Variance Ratio Test.
Example · XLE, XLF, XLK · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_variance_ratio_test:
from financetoolkit import Toolkit
toolkit = Toolkit(
["XLE", "XLF", "XLK"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_variance_ratio_test(method="wright_rank")
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
within_period | bool | Whether to calculate the test within the specified period or for the entire period. Thus whether to look at the test within a specific year (if period = ‘yearly’) or look at the entirety of all years. Defaults to False. Note that this requires intraday data when period = ‘daily’, since a single day only nests observations when intraday data was fetched. | True |
q | int | The number of periods to sum returns over (not used by the Chow-Denning test). Defaults to 2. | 4 |
include_benchmark | bool | Whether to include “Benchmark” among the assets tested. 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 |
method | str | The test. Options are: “lo_mackinlay” (Lo-MacKinlay Variance Ratio Test), “chow_denning” (Chow-Denning Test, the horizons 2, 4, 8 and 16 at once), “wright_rank” (Wright Rank Test, R1), “wright_rank_score” (Wright Rank Score Test, R2), “wright_sign” (Wright Sign Test, S1). Defaults to “lo_mackinlay”. | "lo_mackinlay" |
Which returns:
| Item | XLE | XLF | XLK |
|---|---|---|---|
| Variance Ratio | 1.0335 | 1.0322 | 0.9840 |
| Wright R1 Statistic | 1.1874 | 1.1387 | -0.5671 |
| P-Value | 0.2395 | 0.2630 | 0.5745 |
3 rows
Using Your Own Data
get_variance_ratio_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_variance_ratio_test()
References
- Paper Wright, J.H. (2000). “Alternative Variance-Ratio Tests Using Ranks and Signs.” Journal of Business & Economic Statistics, 18(1), 1-9.