Repository: statsmodels/statsmodels

Issue:
forecast fail in VARProcess class
#### Describe the bug

I got the "AttributeError: 'VARProcess' object has no attribute 'exog'" in forecast method of VARProcess class.

#### Code Sample, a copy-pastable example if possible


```python
import numpy as np
from statsmodels.tsa.vector_ar.var_model import VARProcess

A=np.array([[[.5,0,0],[.1,.1,.3],[0,.2,.3]]])
ν=np.array([0,2,1])
ex1=VARProcess(coefs=A,coefs_exog=ν,sigma_u=None)

y=np.array([[-6,3,5]])
ex1.forecast(y,2)
```
<details>

**Note**: As you can see, there are many issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates.

**Note**: Please be sure you are using the latest released version of `statsmodels`, or a recent build of `master`. If your problem has been fixed in an unreleased version, you might be able to use `master` until a new release occurs. 

**Note**: If you are using a released version, have you verified that the bug exists in the master branch of this repository? It helps the limited resources if we know problems exist in the current master so that they do not need to check whether the code sample produces a bug in the next release.

</details>


If the issue has not been resolved, please file it in the issue tracker.

#### Expected Output

I could directly import forecast function and get the right result as in p34 Lütkepohl(2005):

```python
from statsmodels.tsa.vector_ar.var_model import forecast

forecast(y,ex1.coefs,ex1.coefs_exog,2)
```

#### Output of ``import statsmodels.api as sm; sm.show_versions()``

<details>

INSTALLED VERSIONS
------------------
Python: 3.8.5.final.0

statsmodels
===========

Installed: 0.12.1 (D:\miniconda3\lib\site-packages\statsmodels)

Required Dependencies
=====================

cython: Not installed
numpy: 1.19.2 (D:\miniconda3\lib\site-packages\numpy)
scipy: 1.6.0 (D:\miniconda3\lib\site-packages\scipy)
pandas: 1.2.1 (D:\miniconda3\lib\site-packages\pandas)
    dateutil: 2.8.1 (D:\miniconda3\lib\site-packages\dateutil)
patsy: 0.5.1 (D:\miniconda3\lib\site-packages\patsy)

Optional Dependencies
=====================

matplotlib: 3.3.2 (D:\miniconda3\lib\site-packages\matplotlib)
    backend: module://ipykernel.pylab.backend_inline 
cvxopt: Not installed
joblib: Not installed

Developer Tools
================

IPython: 7.20.0 (D:\miniconda3\lib\site-packages\IPython)
    jinja2: 2.11.3 (D:\miniconda3\lib\site-packages\jinja2)
sphinx: Not installed
    pygments: 2.7.4 (D:\miniconda3\lib\site-packages\pygments)
pytest: Not installed
virtualenv: Not installed

</details>



Discussion:
You don't have enough data.  You need at least 3 data points of 2 series to even consider a forecast.
Got it. I thought I could do it with only known coefficients.
Thanks

Resolving patch:
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
@@ -230,6 +230,11 @@ def forecast(y, coefs, trend_coefs, steps, exog=None):
     """
     p = len(coefs)
     k = len(coefs[0])
+    if y.shape[0] < p:
+        raise ValueError(
+            f"y must by have at least order ({p}) observations. "
+            f"Got {y.shape[0]}."
+        )
     # initial value
     forcs = np.zeros((steps, k))
     if exog is not None and trend_coefs is not None:


Test patch: