Skip to main content

Forecast Model Selection

Forecast model selection tests are statistical methods that determine whether the accuracy difference between two competing forecasting models is statistically significant or merely due to random chance. Without these tests, you might deploy a more complex model that appears better on a single test set but offers no real improvement.


Diebold-Mariano Test

The Diebold-Mariano test is a statistical test that evaluates whether two forecasting models have significantly different predictive accuracy. It compares the loss differential between two sets of forecasts and tests whether the mean difference is statistically distinguishable from zero.

Parameters

ParameterTypeRequiredDefaultDescription
actualDOUBLEYes-Actual values
forecast1DOUBLEYes-First forecast
forecast2DOUBLEYes-Second forecast
optionsMAPNo-Configuration options

Options MAP:

OptionTypeDefaultDescription
lossVARCHARmsemse, mae, or mape
alternativeVARCHARtwo_sidedtwo_sided, less, greater

Output

FieldTypeDescription
statisticDOUBLEDM test statistic
p_valueDOUBLEp-value
better_modelINTEGER1 or 2 (which forecast is better)

Example

SELECT anofox_stats_diebold_mariano_agg(
actual,
forecast1,
forecast2,
MAP {'loss': 'mse'}
) as result
FROM forecast_data;

Clark-West Test

The Clark-West test is designed for comparing nested forecasting models, where one model (restricted) is a special case of the other (unrestricted). It adjusts for the parameter estimation noise that makes the Diebold-Mariano test conservative in nested comparisons. More powerful than Diebold-Mariano when comparing nested models.

Parameters

ParameterTypeRequiredDefaultDescription
actualDOUBLEYes-Actual values
forecast1DOUBLEYes-First forecast (restricted model)
forecast2DOUBLEYes-Second forecast (unrestricted model)

Output

FieldTypeDescription
statisticDOUBLECW test statistic
p_valueDOUBLEp-value

Example

SELECT anofox_stats_clark_west_agg(
actual,
forecast1,
forecast2
) as result
FROM forecast_data;

Choosing Between Tests

ScenarioRecommended Test
Non-nested modelsDiebold-Mariano
Nested modelsClark-West
Large errors matter moreDM with loss: 'mse'
Robust to outliersDM with loss: 'mae'
Percentage errorsDM with loss: 'mape'
🍪 Cookie Settings