Repository: statsmodels/statsmodels

Issue:
VARResults.summary doesn't show all Variables
#### Describe the bug
I developed a VARX (1) Model with 7 endogenous and 15 exogenous Variables. When I create the summary() of the "fit" the results of the equations aren't complete. I only see the constant and first 7 exogenous Variables. The Lags of the other endogenous Variables are completely missing. Furthermore the exogenous Variables don't have their proper names. It only says "exog0, exog1, ...".

results.params() shows all the coefficients correctly. But the names of the exogenous variables are also generic. 

#### Code Sample, a copy-pastable example if possible
model = VAR(df_endog_train, exog=df_exog_train)
result = model.fit(1)
result.summary() 

 Output:

Summary of Regression Results   

Model:                         VAR
Method:                        OLS
Date:           Fri, 18, Oct, 2019
Time:                     11:35:59

No. of Equations:         7.00000    BIC:                   -32.1637
Nobs:                     51.0000    HQIC:                  -35.9318
Log likelihood:           630.126    FPE:                3.93928e-17
AIC:                     -38.2622    Det(Omega_mle):     2.90928e-18

Results for equation NTZ_AUT1

           coefficient       std. error           t-stat            prob

const         0.543775         0.185069            2.938           0.003
exog0        -0.176918         0.032237           -5.488           0.000
exog1        -0.275946         0.081418           -3.389           0.001
exog2         0.778170         0.168673            4.613           0.000
exog3         0.000004         0.000002            2.180           0.029
exog4         0.000006         0.000003            1.918           0.055
exog5         0.000004         0.000010            0.416           0.678
exog6         0.000012         0.000005            2.452           0.014



If the issue has not been resolved, please file it in the issue tracker.

#### Expected Output

I expect that the results of every equation show every coefficient.





Discussion:
This doesn't work the way you think.  fit(maxlag) check lags 0, 1,2,...maxlag, and then selects the best lag length by minimizing an information criteria.  Your model is selecting a lag 0.  You can set ic=None to ignore the IC search and just fit the model you ask.

https://www.statsmodels.org/dev/generated/generated/statsmodels.tsa.vector_ar.var_model.VAR.fit.html#statsmodels.tsa.vector_ar.var_model.VAR.fit


This is an early choice in statsmodels and is probably classified as a mis-feature since it is not consistent with most of statsmodels. 
Oh thats good to know! But why does my result.params() Look like this:
![result_params](https://user-images.githubusercontent.com/56720749/67086069-53881780-f1a0-11e9-8f71-41203c9473d1.PNG)

And even if it selected 0 lags, why does the summary not show all exogenous variables?
You get a model parameter for each of the variables in your VAR. You have a constant 1 exog variables, and 1 lag of each of the 5 variables. 

No idea what is going on with the lag 0 report.  Could be buggy. Are you sure you don't see all exog with 0 lags?
Could be a bug in VAR summary. 
Sorry for the late answer. 

I'm a beginner an I don't know if I understand everything correctly.
![grafik](https://user-images.githubusercontent.com/56720749/67091532-2726c800-f1ad-11e9-92fc-3496124ac318.png)

Doesn't this mean that I created a VARX (1) model?`

And this is a snippet of the Summary I get:
![grafik](https://user-images.githubusercontent.com/56720749/67091575-4887b400-f1ad-11e9-8a94-7bc5ff436865.png)

So there are only 6 out of 15 exogenous and none of the endogenous Variables. And is it normal that the exogenous are called "exog0" and so on? In my source dataframe they have different names.


Confirmed bug.  Use res.params or res.tstats until the next release. 

Resolving patch:
diff --git a/statsmodels/tsa/vector_ar/output.py b/statsmodels/tsa/vector_ar/output.py
--- a/statsmodels/tsa/vector_ar/output.py
+++ b/statsmodels/tsa/vector_ar/output.py
@@ -152,11 +152,10 @@ def _coef_table(self):
         header = ('coefficient','std. error','t-stat','prob')
 
         buf = StringIO()
-        dim = k * model.k_ar + model.k_trend
+        dim = k * model.k_ar + model.k_trend + model.k_exog_user
         for i in range(k):
             section = "Results for equation %s" % model.names[i]
             buf.write(section + '\n')
-            #print >> buf, section
 
             table = SimpleTable(data[dim * i : dim * (i + 1)], header,
                                 Xnames, title=None, txt_fmt = self.default_fmt)
diff --git a/statsmodels/tsa/vector_ar/var_model.py b/statsmodels/tsa/vector_ar/var_model.py
--- a/statsmodels/tsa/vector_ar/var_model.py
+++ b/statsmodels/tsa/vector_ar/var_model.py
@@ -603,13 +603,14 @@ def fit(self, maxlags=None, method='ols', ic=None, trend='c',
             "nc" - co constant, no trend
             Note that these are prepended to the columns of the dataset.
 
-        Notes
-        -----
-        Lütkepohl pp. 146-153
-
         Returns
         -------
-        est : VARResultsWrapper
+        VARResults
+            Estimation results
+
+        Notes
+        -----
+        See Lütkepohl pp. 146-153 for implementation details.
         """
         lags = maxlags
 


Test patch:
diff --git a/statsmodels/tsa/vector_ar/tests/test_var.py b/statsmodels/tsa/vector_ar/tests/test_var.py
--- a/statsmodels/tsa/vector_ar/tests/test_var.py
+++ b/statsmodels/tsa/vector_ar/tests/test_var.py
@@ -2,29 +2,24 @@
 """
 Test VAR Model
 """
-from statsmodels.compat.python import iteritems, lrange
-
-from io import StringIO, BytesIO
-import warnings
-
 import os
 import sys
+import warnings
+from io import StringIO, BytesIO
 
 import numpy as np
 import pandas as pd
-from pandas.util.testing import assert_index_equal
 import pytest
-
+from numpy.testing import (assert_almost_equal, assert_equal,
+                           assert_allclose)
+from pandas.util.testing import assert_index_equal
 
 import statsmodels.api as sm
-import statsmodels.tsa.vector_ar.util as util
 import statsmodels.tools.data as data_util
-from statsmodels.tsa.vector_ar.var_model import VAR, var_acf
+import statsmodels.tsa.vector_ar.util as util
+from statsmodels.compat.python import iteritems, lrange
 from statsmodels.tools.sm_exceptions import ValueWarning
-
-
-from numpy.testing import (assert_almost_equal, assert_equal,
-                           assert_allclose)
+from statsmodels.tsa.vector_ar.var_model import VAR, var_acf
 
 DECIMAL_12 = 12
 DECIMAL_6 = 6
@@ -817,3 +812,28 @@ def test_var_cov_params_pandas(bivariate_var_data):
     index = pd.MultiIndex.from_product((exog_names, ('x', 'y')))
     assert_index_equal(cov.index, cov.columns)
     assert_index_equal(cov.index, index)
+
+
+def test_summaries_exog(reset_randomstate):
+    y = np.random.standard_normal((500, 6))
+    df = pd.DataFrame(y)
+    cols = (["endog_{0}".format(i) for i in range(2)] +
+            ["exog_{0}".format(i) for i in range(4)])
+    df.columns = cols
+    df.index = pd.date_range('1-1-1950', periods=500, freq="MS")
+    endog = df.iloc[:, :2]
+    exog = df.iloc[:, 2:]
+
+    res = VAR(endog=endog, exog=exog).fit(maxlags=0)
+    summ = res.summary().summary
+    assert 'exog0' in summ
+    assert 'exog1' in summ
+    assert 'exog2' in summ
+    assert 'exog3' in summ
+
+    res = VAR(endog=endog, exog=exog).fit(maxlags=2)
+    summ = res.summary().summary
+    assert 'exog0' in summ
+    assert 'exog1' in summ
+    assert 'exog2' in summ
+    assert 'exog3' in summ