title: Regression Method Used in statsmodels adfuller()?
body: <p>What is the method of regression used in <code>adfuller()</code>? I'm performing an augmented dickey fuller test on a time series, and I'm trying two different ways of doing it.</p>
  
  <p>First, I use <code>pandas.diff()</code> to get the change in price <code>dy</code>. Then I'm passing the original time series as an independent variable <code>y</code> along with <code>dy</code> as the dependent into <code>statsmodels.OLS(dy,y)</code> and getting the results. Then, I extract the slope parameter, <code>model.params[1]</code> and the standard error of the slope parameter <code>model.bse[1]</code>. The quotient of these terms is the Dickey Fuller test statistic I call <code>DF = model.params[1]/model.bse[1]</code>. </p>
  
  <p>Second, I pass the singular time price series into <code>adfuller()</code> as such:</p>
  
  <pre><code>adfstat, pvalue, critvalues, resstore = ts.adfuller(y.y,regression='c',store=True,regresults=True)
  </code></pre>
  
  <p>Now, to get the Dickey Fuller test statistic, I simply pass
  <code>DF = resstore.tvalues[1]</code></p>
  
  <p>Using OLS I get:</p>
  
  <pre><code>DF = -1.81495580198
  </code></pre>
  
  <p>With adfuller():</p>
  
  <pre><code>DF = -1.56386414181
  </code></pre>
  
  <p>I'm wondering what is the difference between these two methods? Does adfuller() perform a different linear regression than OLS internally? I've observed that the results from OLS are undeniably correct according to a book that I'm getting examples from. But I prefer to use adfuller() because it provides the critical values for the test statistic as a part of the output. Additionally, it seems that there are many regression coefficients for the adfuller() result:</p>
  
  <pre><code>print resstore.resols.params ==&gt; 
  [-0.00491391  0.02366782 -0.00295179  0.01354619  0.06399901 -0.06018851
   -0.00328142 -0.03876784  0.02934003 -0.10224276  0.00227549  0.01042279
   -0.04627873  0.05503934 -0.02707106  0.02664511 -0.02428741  0.04894767
   -0.06206492  0.00508655]
  </code></pre>
  
  <p>I determine the halflife for mean reversion by getting the slope of the regression line. It looks here that <code>adfuller()</code> is computing a 20th order regression? This doesn't seem right. Maybe I'm doing this wrong though? Can somebody shed some light on <code>adfuller()</code>?</p>