Ich glaube nicht, dass ein Kointegrationstest für scipy implementiert wurde. Sie können besser using rpy2
sein, um Python mit R zu verbinden. R liefert Kointegrationstests im urca
package.
Zum Beispiel:
import rpy2.robjects as ro
r=ro.r
a = [10.23, 11.65, 12.36, 12.96]
b = [5.23, 6.10, 8.3, 4.98]
definieren a
und b
in R:
ro.globalEnv['a']=ro.FloatVector(a)
ro.globalEnv['b']=ro.FloatVector(b)
aufrufen R cor
(Korrelation) Funktion:
print(r('cor(a,b,method="pearson")'))
# [1] 0.2438518
aufrufen R ca.po
(Phillips & Ouliaris Kointegration-Test)
r('library(urca)')
print(r('ca.po(cbind(a,b))'))
# ########################################################
# # Phillips and Ouliaris Unit Root/Cointegration Test #
# ########################################################
# The value of the test statistic is: 0
Ich bin nicht vertraut mit Kointegration jedoch so entschuldigen, wenn meine Verwendung von ca.po
völlig unfähigen ist.
Beachten Sie auch, dass R die Programmiersprache für sich ist, mit (zumindest derzeit) eine reichere Bibliothek von statistischen Funktionen als scipy
. Es ist möglich, R direkt (ohne Python) auszuführen. Die Anrufe aussehen würde, ein wenig einfacher:
> a = c(10.23, 11.65, 12.36, 12.96)
> b = c(5.23, 6.10, 8.3, 4.98)
> z = cbind(a,b)
> z
a b
[1,] 10.23 5.23
[2,] 11.65 6.10
[3,] 12.36 8.30
[4,] 12.96 4.98
> ca.po(z)
########################################################
# Phillips and Ouliaris Unit Root/Cointegration Test #
########################################################
The value of the test statistic is: 0
http://stackoverflow.com/questions/12186994/johansen-cointegration-test-in-python – gliptak