Python 中与 MATLAB 中的 `vratiotest` 等效函数是 `scipy.stats.fisher_exact`。

huangapple go评论70阅读模式
英文:

python equivalent for MATLABS vratiotest

问题

我正在跟随《Algorithmic Trading》这本书,目前在第2章:均值回归的基础部分。

我有一些货币对及其收盘价格,我想检查哪一对的价差是均值回归的。

该书中使用MATLAB进行所有编程,而我正在使用Python。

首先提到了MATLAB包中的adf函数,其等价的Python代码是:

from statsmodels.tsa.stattools import adfuller
ad = adfuller(spread, maxlag=1)

然后提到了cadf,我认为其等价的Python代码是:

from statsmodels.tsa.stattools import coint
t_statistic, p_value, crit_value = coint(x, y)

然而,我找不到MATLAB的vratiotest的Python等价物。请告诉我是否有一个Python函数可以执行与MATLAB的vratiotest相同的功能。

英文:

I am following the book Algorithmic Trading and I am on Chapter 2: The Basics of Mean Reversion.

I have a few pairs and their close prices and I want to check the spread of which pair is mean-reverting.

The book uses MATLAB for all its programming and I am using Python.

First, there was a mention of adf function in MATLAB's package and its equivalent python code is:

from statsmodels.tsa.stattools import adfuller
ad = adfuller(spread, maxlag = 1)

Then there is a mention of cadf and I think its equivalent python code is:

from statsmodels.tsa.stattools import coint
t_statistic, p_value, crit_value = coint(x, y)

However, I cannot find the python equivalent for MATLAB's vratiotest.

Please let me know if there is a python function which performs same as MATLAB's vratiotest.

答案1

得分: 0

https://arch.readthedocs.io/en/latest/unitroot/generated/arch.unitroot.VarianceRatio.html

arch.unitroot.VarianceRatio

from arch.unitroot import VarianceRatio

https://mingze-gao.com/posts/lomackinlay1988/

英文:

These may not be exactly what you are looking for:

https://arch.readthedocs.io/en/latest/unitroot/generated/arch.unitroot.VarianceRatio.html

arch.unitroot.VarianceRatio

from arch.unitroot import VarianceRatio

Here is the python code for Variance Ratio Test - Lo and MacKinlay

https://mingze-gao.com/posts/lomackinlay1988/

huangapple
  • 本文由 发表于 2023年3月9日 13:50:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75680861.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定