def VAR(x, B, const=0):
 p = B.shape[0]
 T = x.shape[0]
 xhat = np.zeros(x.shape)
 for t in range(p, T):
  xhat[t, :] = (const + (x[(t - p):t, :, np.newaxis] * B).sum(axis=1).sum(axis=0))
 return xhat

def VAR ( x , B , const = 0 ) : p = B . shape [ 0 ] T = x . shape [ 0 ] xhat = np . zeros ( x . shape ) for t in range ( p , T ) : xhat [ t , : ] = ( const + ( x [ ( t - p ) : t , : , np . newaxis ] * B ) . sum ( axis = 1 ) . sum ( axis = 0 ) ) return xhat
multivariate linear filter parameters x: array columns are variables .