Jordan Adamson found an error in the code that Solomon Hsiang developed to compute Conley standard errors in Stata. Unfortunately, we transcribed this error when we implemented Hsiang’s code in C++ and R. These errors happen, and Hsiang clearly warns users at the top of his code.

The problem is a single misplaced parathesis in the line calcluating the weight for the Bartlett kernel when correcting for temporal auto-correlation: weight = (1:-abs(time1[t,1] :- time1))/(lag_cutoff+1) (line 430 in the original ado file, version dated 4/29/2013).

Per Newey and West (1987), the Bartlett kernel is

However, the line above instead computes:

The fix is simple: the third parenthesis needs to be moved to the end of the line. Unfortunately, the fix is also consequential, as the uncorrected code can deliver negative weights and lead to standard errors that are too small when there is positive temporal auto-correlation.

Our old and new code is now posted in a public GitHub repo.

Original Code

Here’s the original Stata implementation.

This code delivers the following standard errors:

And our original C++/R implementation:

This matches the standard errors from the Stata output.

Corrected Code

Jordan caught the transcribed error on line 183 of our C++ code. Per Newey and West (1987), we correct (1 - t_diff[j]) / (cutoff + 1) to (1 - t_diff[j] / (cutoff + 1)) and recompute the standard errors.

As is apparent from the final column, correcting the error meaningfully changes the standard errors in the last column. Thiemo’s data is a bit unusual; in other applications with positive temporal auto-correlation, we find that the standard errors tend to increase with the corrected code.