apoorvalal / ivDiag

IV diagnostics package accompanying Lal, Lockhart, Xu, and Zu (2023).
https://arxiv.org/abs/2303.11399
Other
8 stars 4 forks source link

Reports incorrect analytic clustered SEs? #6

Closed mmooddaa closed 11 months ago

mmooddaa commented 11 months ago

Love this package (and the paper), thanks for making it!

I have noticed one potential issue though. My expectation is that model$est_2sls should report the clustered standard errors if you provide a cluster variable to the ivDiag function. But I found that the clustered analytic SEs differed from what lfe produces on its own. Also, ivDiag outputs the same analytic SEs through whether you cluster or not. I am using version 1.0.4.

I think the problem is that the robustify helper function in utils.R is extracting the robust SE rather than the clustered SE. See this line: https://github.com/apoorvalal/ivDiag/blob/5983aeaddcddba0f1364d33961311a42e422d5d1/R/utils.R#L216

I believe this should be extracting model$cse if there is clustering.

xuyiqing commented 11 months ago

Thank you so much. I'll look into this during the weekend!

On Fri, Sep 15, 2023 at 5:21 AM mmooddaa @.***> wrote:

Love this package (and the paper), thanks for making it!

I have noticed one potential issue though. My expectation is that model$est_2sls should report the clustered standard errors if you provide a cluster variable to the ivDiag function. But I found that the clustered analytic SEs differed from what lfe produces on its own. Also, ivDiag outputs the same analytic SEs through whether you cluster or not. I am using version 1.0.4.

I think the problem is that the robustify helper function in utils.R is extracting the robust SE rather than the clustered SE. See this line: https://github.com/apoorvalal/ivDiag/blob/5983aeaddcddba0f1364d33961311a42e422d5d1/R/utils.R#L216

I believe this should be extracting model$cse if there is clustering.

— Reply to this email directly, view it on GitHub https://github.com/apoorvalal/ivDiag/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGCFDNXMQZJKDGAY6E3X2RB3LANCNFSM6AAAAAA4ZXLGKU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Yiqing Xu

Assistant Professor Department of Political Science Stanford University https://yiqingxu.org/

xuyiqing commented 11 months ago

I have fixed the bugs. Thank you so much for reporting them!

mmooddaa commented 11 months ago

Happy to help. Thank you for the great software!