Error in <fitstat (iv_tsls_fe, "kpr")> – non-compatible array dimensions in the expression involving "vcov" and "vcovClust"

huangapple go评论54阅读模式
英文:

Error in <fitstat (iv_tsls_fe, "kpr")> - non-compatible array dimensions in the expression involving "vcov" and "vcovClust"

问题

这是我第一次来到您的博客,如果可能的话,我需要您的亲切帮助或建议来解决我即将描述的问题。

我和我的团队使用R进行了以下的固定效应OLS估计:

iv_tsls_fe <- feols(mort_u65_pop ~ year + datacoverage + GDP + unemployment_rate + at_risk_poverty | clust2  | pm25 ~ rain_yr_mm + temp_c + wdsp, data = df2, vcov = vcov_cluster("clust2"))

我们正在使用"feols"函数估计固定效应工具变量(IV)模型。因变量是"mort_u65_pop",自变量包括"year"、"datacoverage"、"GDP"、"unemployment_rate"和"at_risk_poverty"。工具变量是"rain_yr_mm"、"temp_c"和"wdsp"。我们使用"vcov_cluster"来计算"fixest"对象的集群VCOV。在我们的情况下,"clust2"是数据集"data = df2"中的一个变量。

然后,我们计算了固定对象的拟合统计信息如下:

fitstat(iv_tsls_fe, "ivwald")
fitstat(iv_tsls_fe, "cd")

fitstat(iv_tsls_fe, "kpr")

尽管弱工具的Wald和The Cragg-Donald测试有效,但对于弱工具的Kleibergen-Paap测试,我遇到了以下错误:

Error in vcov + (-1)^(i + 1) * vcovClust(index, bread, scores, adj = ssc$cluster.adj &&  : 
  non-conformable arrays

不幸的是,我们无法找出问题出在哪里,因为前两个测试有效。

是否有人有关于如何处理这个问题的建议?我将非常感激。

我希望我的陈述清楚,如果我漏掉了什么,我仍然可以提供进一步的细节。

非常感谢您,
Lorena

英文:

This is my first time to your blog and I would need your kind help or advice, if possible to solve the problem I am about to describe.

Me and my team have estimated the following fixed effects OLS estimation using R:

iv_tsls_fe &lt;- feols(mort_u65_pop ~ year + datacoverage + GDP + unemployment_rate + at_risk_poverty | clust2  | pm25 ~ rain_yr_mm + temp_c + wdsp, data = df2, vcov = vcov_cluster(&quot;clust2&quot;))

Where we are estimating a fixed-effects instrumental variable (IV) model using the "feols" function. The dependent variable is "mort_u65_pop," and the independent variables include "year", "datacoverage", "GDP", "unemployment_rate" and "at_risk_poverty." The instrumental variables are "rain_yr_mm", "temp_c" and "wdsp". We use "vcov_cluster" to compute the clustered VCOV of fixest objects. In our case "clust2" is a variable inside the dataset "data = df2".

And then we have computed the fit statistics of fixed objects as follows:

fitstat(iv_tsls_fe, &quot;ivwald&quot;)
fitstat(iv_tsls_fe, &quot;cd&quot;)

fitstat(iv_tsls_fe, &quot;kpr&quot;)

Although Wald and The Cragg-Donald tests for weak instrument work, for what concerns the The Kleibergen-Paap test for weak instruments I encounter the following error:

Error in vcov + (-1)^(i + 1) * vcovClust(index, bread, scores, adj = ssc$cluster.adj &amp;&amp;  : 
  non-conformable arrays

Unfortunately, we can't figure out where the problem lies, since the previous two tests work.

Would anyone have any suggestions on how to handle this problem? I would be very grateful.

I hope I have been clear in my presentation and remain available to provide further details in case I missed something.

Thank you very much,
Lorena

答案1

得分: 1

我认为这里的问题可能是由于集群误差与该包中的Kleibergen-Paap测试不兼容所致。我也遇到过这个错误,并注意到只有在我使用集群误差时才会出现这个错误,如果在您的情况下也是如此,我会感兴趣的。

不幸的是,我不知道如何在fixest内部直接修复这个问题。我当前的解决方案是利用ivDiag进行IV诊断。虽然在我的情况下,涉及的固定效应数量较少,当使用fixest时可能会有更多固定效应,但ivDiag的后端是来自lfe的felm,因此即使涉及非常多的固定效应也应该没有问题。还要注意的一点是,ivDiag实际上并不报告KP测试,但它报告Montiel Olea和Pflueger的有效f统计量,这在只有一个被识别的情况下等同于KP测试,并且似乎至少被这篇论文的作者所偏爱:"https://scholar.harvard.edu/files/wirev_092218-_corrected_0.pdf"。

抱歉我不能提供更多帮助,但我希望这对您有所帮助。

英文:

I think the issue here may be due to clustered errors not playing well with the Kleibergen-Paap test in this package. I have also had this error and noticed it only appeared when I was using clustered errors and would be interested if it is the same in your case.

Unfortunately I don't know of any direct fix for this within fixest. My current solution is to utilise ivDiag for my IV diagnostics. While in my case the number of fixed effects involved is on the lower end as to what one may have when using fixest, the backend of ivDiag is felm from lfe so it should be fine even for very large numbers of fixed effects. One last thing to note is that ivDiag doesn't actually report the KP test, however it does report the Montiel Olea & Pflueger effective f-statistic which reduces to the KP test in the just identified case and seems to be preferred to the kp test by at least the authors of this paper "https://scholar.harvard.edu/files/wirev_092218-_corrected_0.pdf".

Apologies for not being more help, however I hope that this is of some assistance.

huangapple
  • 本文由 发表于 2023年7月4日 20:20:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76612564.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定