title: How to manually forecast a statsmodels VAR (Vector Autoregression) model
body: <p>I have 4 time series that I ran a statsmodels VAR model on. The specific import statement (in case there are multiple VAR implementations) is</p>
  <pre><code>from statsmodels.tsa.api import VAR
  </code></pre>
  <p>I am specifically interested in forecasting one of the 4 series. I fit the VAR model, and ran the &quot;forecast&quot; method, forecasts looking OK. Now, I want to also manually run those forecasts myself to make sure I understand the implementation under the hood (and because as a next step I want to plug independent forecasts for the explanatory series and use the model's coefficients to project my target series).</p>
  <p>When I use the model's trained coefficients to make linear combinations of the lagged values for all the series (I have doubled and triple checked that my ordering is correct on the coefficients) and use a forecast, I get a different result:</p>
  <p><a href="https://i.stack.imgur.com/pezBO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pezBO.png" alt="enter image description here" /></a></p>
  <p>If I extend the forecasting horizon even further, variance seems to tend to infinity</p>
  <p><a href="https://i.stack.imgur.com/xBJj7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xBJj7.png" alt="enter image description here" /></a></p>
  <p>Here is the statsmodels documentation on their forecast method</p>
  <p><a href="https://www.statsmodels.org/dev/vector_ar.html#forecasting" rel="nofollow noreferrer">https://www.statsmodels.org/dev/vector_ar.html#forecasting</a></p>
  <p>They mention that &quot;the linear predictor is the optimal h-step ahead forecast in terms of mean-squared error.&quot; Does that mean they run some sort of optimization on top of this? Or are they just repeating the fact that this model was trained with a MSE loss function?</p>
  <p>If it's impossible to provide any constructive feedback from this description I'll put together a simple example, but perhaps I'm missing something obvious.</p>