def S_hac_simple(x, nlags=None, weights_func=weights_bartlett):
 if (x.ndim == 1):
  x = x[:, None]
 n_periods = x.shape[0]
 if (nlags is None):
  nlags = int(np.floor((4 * ((n_periods / 100.0) ** (2.0 / 9.0)))))
 weights = weights_func(nlags)
 S = (weights[0] * np.dot(x.T, x))
 for lag in range(1, (nlags + 1)):
  s = np.dot(x[lag:].T, x[:(- lag)])
  S += (weights[lag] * (s + s.T))
 return S

def S_hac_simple ( x , nlags = None , weights_func = weights_bartlett ) : if ( x . ndim == 1 ) : x = x [ : , None ] n_periods = x . shape [ 0 ] if ( nlags is None ) : nlags = int ( np . floor ( ( 4 * ( ( n_periods / 100.0 ) ** ( 2.0 / 9.0 ) ) ) ) ) weights = weights_func ( nlags ) S = ( weights [ 0 ] * np . dot ( x . T , x ) ) for lag in range ( 1 , ( nlags + 1 ) ) : s = np . dot ( x [ lag : ] . T , x [ : ( - lag ) ] ) S += ( weights [ lag ] * ( s + s . T ) ) return S
inner covariance matrix for hac sandwich assumes we have a single time series with zero axis consecutive .