Clark-West Test

Calculate the Clark-West test per asset: whether an autoregressive forecast predicts the next return better than the historical average, the model it nests.

The historical average is the benchmark of return predictability (Welch and Goyal, 2008); the AR(1) forecast adds yesterday’s return as a predictor. The larger model has to estimate a slope that is zero when returns are unpredictable, which adds noise to its forecasts, so comparing the plain mean squared prediction errors (as the Diebold-Mariano test does) favours the historical average too much. Clark and West correct the larger model’s errors for that noise and test one-sided: a positive statistic above 1.645 (5%) means the AR(1) forecast is better.

The formula is as follows:

\[\hat{y}_{1,t} = \frac{\sum_{i=1}^{\texttt{window}} r_{t-i}}{\texttt{window}}\] \[\hat{y}_{2,t} = a + b \cdot r_{t-1}\] \[f_{t} = (r_{t} - \hat{y}_{1,t})^{2} - \left((r_{t} - \hat{y}_{2,t})^{2} - (\hat{y}_{1,t} - \hat{y}_{2,t})^{2}\right)\] \[\text{CW} = \frac{\operatorname{mean}\left(f\right)}{\text{SE}\left(\operatorname{mean}\left(f\right)\right)}\] \[\text{SE}\left(\operatorname{mean}\left(f\right)\right) = \frac{s}{\sqrt{n}}\] \[\text{P Value} = 1 - \Phi(\text{CW})\]

with hat(y_{1,t}) the historical average of the window (252 by default) returns up to t - 1 and hat(y_{2,t}) the AR(1) forecast, with a and b fitted by least squares on the window pairs of returns up to t - 1. s is the standard deviation of f (ddof = 1); with lags above 0 (0 by default) the standard error is its Newey-West version. The p-value is one-sided, with Phi the standard normal distribution function.

Also known as: CW test, MSPE-adjusted test, nested forecast comparison.

Example · ^GSPC, BTCUSD, TLT · 2016 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_clark_west_test:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["^GSPC", "BTCUSD", "TLT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2016-01-01",
    end_date="2025-12-31",
)

toolkit.econometrics.get_clark_west_test(period="weekly", window=104)

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

Did a forecasting model beat a random walk for the weekly returns of the S&P 500, Bitcoin and the iShares 20+ Year Treasury Bond ETF from 2016 to 2025, by the Clark-West test with a two-year rolling window?

Which returns:

Using Your Own Data

get_clark_west_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_clark_west_test()

Parameters

get_clark_west_test accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”, since window is expressed in return observations of this frequency."weekly"
windowintThe number of returns (or pairs of returns) both forecasts are estimated on, at least 3. Defaults to 252.20
lagsintThe Newey-West lags of the standard error, 0 for the ordinary one. Defaults to 0.2
include_benchmarkboolWhether to include “Benchmark” among the assets tested. Defaults to False.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None.2
show_columnsstr | list[str] | NoneThe 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

References

  • Paper Clark, T.E. and West, K.D. (2007). “Approximately Normal Tests for Equal Predictive Accuracy in Nested Models.” Journal of Econometrics, 138(1), 291-311.
  • Paper Welch, I. and Goyal, A. (2008). “A Comprehensive Look at the Empirical Performance of Equity Premium Prediction.” The Review of Financial Studies, 21(4), 1455-1508.
  • Library Shares similar logic as statsmodels’ OLS
Share