简体   繁体   中英

IV Estimation with Cluster Robust Standard Errors using the plm package in R

I'm using the plm package for panel data to do instrumental variable estimation. However, it seems that calculating cluster robust standard errors by using the vcovHC() function is not supported. More specifically, when I use the vcovHC() function, the following error message is displayed:

Error in vcovG.plm(x, type = type, cluster = cluster, l = 0, inner = >inner, : Method not available for IV

Example:

data("Wages", package = "plm")
IV <- plm(lwage ~ south + exp | wks + south,
      data = Wages, model = "pooling", index = 595)

vcvIV <- vcovHC(IV)

According to this thread , someone worked on a fix two years ago. Is there any progress on the issue? I know that the packages "lfe" and "ivpack" allow to compute cluster robust standard errors for IV estimation but none of them allows for random effects/intercepts.

In fact it's not implemented. However, you can use Schrimpf's clustered errors function which is applied directly to a object of the plm class. Using your example:

library (plm)

data("Wages", package = "plm")

IV <- plm(lwage ~ south + exp | wks + south, data = Wages, model = "pooling", index = 595)

Wages$id <- rep(1:595, each = 7)        

cl.plm(Wages, IV, Wages$id)

Where I'm using Wages$id as the panel first dimension around which clusters will be formed. You may want to compare these results with the obtained in other software. Anyway, the code is simple allowing some tricks. The cl.plm function is based on Arai's clustering notes which can help you further.

You can obtain the same result from cl.plm doing this in Stata:

ivregress 2sls lwage south (exp = wks), vce(cluster id) small

Or for the within model:

xtset id time, generic

xtivreg2 lwage south (exp = wks), fe small cluster(id)

Note however I used the small sample formulation in Stata, which is not big deal. More about this here . Anyway, cl.plm properly deals with the plm class object.

For sake of completeness: as suggested by @Helix123, you can use the development version (1.6-1) of plm package and proceed as you did in tour question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM