Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't believe a cointegration test has been implemented for scipy. You may be better off <a href="http://rpy.sourceforge.net/rpy2.html" rel="noreferrer">using <code>rpy2</code></a> to interface Python with R. R provides cointegration tests in the <a href="http://cran.r-project.org/web/packages/urca/index.html" rel="noreferrer"><code>urca</code> package</a>.</p> <p>For example:</p> <pre><code>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] </code></pre> <p>Define <code>a</code> and <code>b</code> in R:</p> <pre><code>ro.globalEnv['a']=ro.FloatVector(a) ro.globalEnv['b']=ro.FloatVector(b) </code></pre> <p>Call the R <code>cor</code> (correlation) function:</p> <pre><code>print(r('cor(a,b,method="pearson")')) # [1] 0.2438518 </code></pre> <p>Call the R <code>ca.po</code> (Phillips &amp; Ouliaris Cointegration Test) </p> <pre><code>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 </code></pre> <p>I'm not familiar with cointegration, however, so apologies if my use of <code>ca.po</code> is totally inept.</p> <p>Also note that R is programming language unto itself, with (at least currently) a richer library of statistical functions than <code>scipy</code>. It's possible to run R directly (without Python). The calls would look a little simpler:</p> <pre><code>&gt; a = c(10.23, 11.65, 12.36, 12.96) &gt; b = c(5.23, 6.10, 8.3, 4.98) &gt; z = cbind(a,b) &gt; z a b [1,] 10.23 5.23 [2,] 11.65 6.10 [3,] 12.36 8.30 [4,] 12.96 4.98 &gt; ca.po(z) ######################################################## # Phillips and Ouliaris Unit Root / Cointegration Test # ######################################################## The value of the test statistic is: 0 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload