title: python - covariance matrix: HAC and Cluster?
body: <p>I am trying to figure out how to compute standard errors in Python. In my dataset, I have panel time series data and I am running AR regressions on them. I have found how to cluster by individuals in the panel:</p>
  
  <pre><code>sm.ols(formula='y ~ x', data=df).fit(cov_type='cluster',cov_kwds={'groups': df['year']},use_t=True) 
  </code></pre>
  
  <p>And I also found how to compute Newey-West standard errors:</p>
  
  <pre><code>sm.ols(formula='y ~ x', data=df).fit(cov_type='HAC',cov_kwds={'maxlags': 3},use_t=True)
  </code></pre>
  
  <p>But does anyone know how to combine the two? In Stata, this would be ivreg2 y x, cluster(time group).</p>
  
  <p>Thanks!</p>