def forecast(y, coefs, intercept, steps):
 p = len(coefs)
 k = len(coefs[0])
 forcs = (np.zeros((steps, k)) + intercept)
 for h in range(1, (steps + 1)):
  f = forcs[(h - 1)]
  for i in range(1, (p + 1)):
   if ((h - i) <= 0):
    prior_y = y[((h - i) - 1)]
   else:
    prior_y = forcs[((h - i) - 1)]
   f = (f + np.dot(coefs[(i - 1)], prior_y))
  forcs[(h - 1)] = f
 return forcs

def forecast ( y , coefs , intercept , steps ) : p = len ( coefs ) k = len ( coefs [ 0 ] ) forcs = ( np . zeros ( ( steps , k ) ) + intercept ) for h in range ( 1 , ( steps + 1 ) ) : f = forcs [ ( h - 1 ) ] for i in range ( 1 , ( p + 1 ) ) : if ( ( h - i ) <= 0 ) : prior_y = y [ ( ( h - i ) - 1 ) ] else : prior_y = forcs [ ( ( h - i ) - 1 ) ] f = ( f + np . dot ( coefs [ ( i - 1 ) ] , prior_y ) ) forcs [ ( h - 1 ) ] = f return forcs
produce linear mse forecast parameters y : coefs : intercept : steps : returns forecasts : ndarray notes lutkepohl p .