title: Statsmodels (Python): Breusch Godfrey Lagrange Multiplier tests
body: <p>I am working with an autoregressive model in Python using Statsmodels. The package is great and I am getting the exact results I need. However, testing for residual correlation (Breusch-Godfrey LM-test) doesn't seem to work, because I get an error message.</p>
  
  <p>My code:</p>
  
  <pre><code>import pandas as pd
  import datetime
  import numpy as np
  from statsmodels.tsa.api import VAR
  import statsmodels.api as sm
  
  df = pd.read_csv('US_data.csv')
  
  # converting str formatted dates to datetime and setting the index
  j = []
  for i in df['Date']:
      j.append(datetime.datetime.strptime(i, '%Y-%m-%d').date())
  df['Date'] = j
  df = df.set_index('Date')
  
  # dataframe contains three columns (GDP, INV and CONS)
  
  # log difference
  df = pd.DataFrame(np.log(df)*100)
  df = df.diff()
  
  p = 4 # order
  model = VAR(df[1:])
  results = model.fit(p, method='ols')
  sm.stats.diagnostic.acorr_breusch_godfrey(results)
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-6-11abf518baae&gt; in &lt;module&gt;()
  ----&gt; 1 sm.stats.diagnostic.acorr_breusch_godfrey(results)
  
  /home/****/anaconda3/lib/python3.6/site-packages/statsmodels/sandbox/stats/diagnostic.py in acorr_breusch_godfrey(results, nlags, store)
      501         nlags = int(nlags)
      502 
  --&gt; 503     x = np.concatenate((np.zeros(nlags), x))
      504 
      505     #xdiff = np.diff(x)
  
  ValueError: all the input arrays must have same number of dimensions
  </code></pre>
  
  <p>A similar question was asked <a href="https://stackoverflow.com/questions/46302347/multivariate-breusch-godfrey-lagrange-multiplier-tests-in-python">here</a> over five months ago, but with no luck. Does anybody have an idea how to resolve this? Thank you very much in advance!</p>