All Projects → johntwk → Diebold-Mariano-Test

johntwk / Diebold-Mariano-Test

Licence: MIT license
This Python function dm_test implements the Diebold-Mariano Test (1995) to statistically test forecast accuracy equivalence for 2 sets of predictions with modification suggested by Harvey et. al (1997).

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Diebold-Mariano-Test

Forecasting Mutual Funds
This Project gives you an overall idea for Forecasting Mutual Funds
Stars: ✭ 15 (-78.57%)
Mutual labels:  prediction, forecasting
arima
ARIMA, SARIMA, SARIMAX and AutoARIMA models for time series analysis and forecasting in the browser and Node.js
Stars: ✭ 31 (-55.71%)
Mutual labels:  prediction, forecasting
verif
Software for verifying weather forecasts
Stars: ✭ 70 (+0%)
Mutual labels:  prediction, forecasting
forecastVeg
A Machine Learning Approach to Forecasting Remotely Sensed Vegetation Health in Python
Stars: ✭ 44 (-37.14%)
Mutual labels:  prediction, forecasting
Ergo
A Python library for integrating model-based and judgmental forecasting
Stars: ✭ 82 (+17.14%)
Mutual labels:  prediction, forecasting
foot
foot是一个集足球数据采集器,简单分析的项目.AI足球球探为程序全自动处理,全程无人为参与干预足球分析足球预测程序.程序根据各大指数多维度数据,结合作者多年足球分析经验,精雕细琢,集天地之灵气,汲日月之精华,历时七七四十九天,经Bug九九八十一个,编码而成.有兴趣的朋友,可以关注一下公众号AI球探(微信号ai00268).
Stars: ✭ 96 (+37.14%)
Mutual labels:  prediction, forecasting
point-cloud-prediction
Self-supervised Point Cloud Prediction Using 3D Spatio-temporal Convolutional Networks
Stars: ✭ 97 (+38.57%)
Mutual labels:  prediction, forecasting
Neural prophet
NeuralProphet - A simple forecasting model based on Neural Networks in PyTorch
Stars: ✭ 1,125 (+1507.14%)
Mutual labels:  prediction, forecasting
Tcdf
Temporal Causal Discovery Framework (PyTorch): discovering causal relationships between time series
Stars: ✭ 217 (+210%)
Mutual labels:  prediction, forecasting
Sales-Prediction
In depth analysis and forecasting of product sales based on the items, stores, transaction and other dependent variables like holidays and oil prices.
Stars: ✭ 56 (-20%)
Mutual labels:  prediction, forecasting
notebooks
Code examples for pyFTS
Stars: ✭ 40 (-42.86%)
Mutual labels:  forecasting
cfdm
A Python reference implementation of the CF data model
Stars: ✭ 24 (-65.71%)
Mutual labels:  forecasting
SCINet
Forecast time series and stock prices with SCINet
Stars: ✭ 28 (-60%)
Mutual labels:  forecasting
reinforcement learning course materials
Lecture notes, tutorial tasks including solutions as well as online videos for the reinforcement learning course hosted by Paderborn University
Stars: ✭ 765 (+992.86%)
Mutual labels:  prediction
Github-Stars-Predictor
It's a github repo star predictor that tries to predict the stars of any github repository having greater than 100 stars.
Stars: ✭ 34 (-51.43%)
Mutual labels:  prediction
R Unet
Video prediction using lstm and unet
Stars: ✭ 25 (-64.29%)
Mutual labels:  prediction
task-ts
Work related to time series prediction and forecasting of Coronavirus
Stars: ✭ 19 (-72.86%)
Mutual labels:  time-series-forecast
PyDREAM
Python Implementation of Decay Replay Mining (DREAM)
Stars: ✭ 22 (-68.57%)
Mutual labels:  prediction
btcpredict
📈 Bitcoin bull run peak prediction project (price and date)
Stars: ✭ 36 (-48.57%)
Mutual labels:  prediction
infer
🔮 Use TensorFlow models in Go to evaluate Images (and more soon!)
Stars: ✭ 65 (-7.14%)
Mutual labels:  prediction

Diebold-Mariano Test

This Python function dm_test implements the Diebold-Mariano Test (1995) with modification suggested by Harvey et. al (1997) to statitsitcally identify forecast accuracy equivalance for 2 sets of predictions.

Description

Suppose that the difference between the first list of prediction and the actual values is e1 and the second list of prediction and the actual value is e2. The length of time-series is T.
Then d can be defined based on different criterion (crit).

  1. MSE : d = (e1)^2 - (e2)^2
  2. MAD : d = abs(e1) - abs(e2)
  3. MAPE: d = abs((e1 - actual)/(actual))
  4. Poly: d = (e1)^power - (e2)^power
The null hypothesis is E[d] = 0.

The test statistics follow the student-T distribution with degree of freedom (T - 1).

File

File Name Description
1. dm_test.py This file contains the function to implement the DM test.

Input

Input Parameter Description
1. actual_lst The list of actual values
2. pred1_lst The first list of predicted values
3. pred2_lst The second list of predicted values
4. h The number of steps ahead of the prediction. The default value is 1.
5. crit A string specifying the criterion. The default value is MSE.
6. power The power for crit equal "poly". It is only meaningful when crit is "poly". The default value is 2. (i.e. E[d] = (e1)^2 - (e2)^2)

Return

Names of Return Description
1. DM The DM test statistics
2. p-value The p-value of DM test statistics

Example

Sample Script:

from dm_test import dm_test
import random

random.seed(123)
actual_lst = range(0,100)
pred1_lst = range(0,100)
pred2_lst = range(0,100)

actual_lst = random.sample(actual_lst,100)
pred1_lst = random.sample(pred1_lst,100)
pred2_lst = random.sample(pred2_lst,100)

rt = dm_test(actual_lst,pred1_lst,pred2_lst,h = 1, crit="MAD")
print rt
rt = dm_test(actual_lst,pred1_lst,pred2_lst,h = 1, crit="MSE")
print rt
rt = dm_test(actual_lst,pred1_lst,pred2_lst,h = 1, crit="poly", power=4)
print rt

Output:

dm_return(DM=1.3275742446369585, p_value=0.18737195617455585)
dm_return(DM=1.2112523589452902, p_value=0.22868210381769466)
dm_return(DM=0.9124498079287283, p_value=0.36374861695187799)

Reference

Harvey, D., Leybourne, S., & Newbold, P. (1997). Testing the equality of prediction mean squared errors. International Journal of forecasting, 13(2), 281-291.

Diebold, F. X. and Mariano, R. S. (1995), Comparing predictive accuracy, Journal of business & economic statistics 13(3), 253-264.

Licence

MIT License

Copyright (c) 2017 John Tsang

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].