5

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.

Community
  • 1
  • 1
André
  • 55
  • 4
  • Unfortunately, you will have to wait until it is implemented...you can track the development version of plm here: https://r-forge.r-project.org/R/?group_id=406 – Helix123 Nov 02 '16 at 09:11
  • Thank you for your response. Are you currently planning to implement it any time soon? – André Nov 02 '16 at 10:29
  • The official CRAN release (1.6-4) of plm now has that incorporated. – Helix123 Nov 30 '16 at 08:18

1 Answers1

2

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$idas 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.

jay.sf
  • 60,139
  • 8
  • 53
  • 110
Rodrigo Remedio
  • 640
  • 6
  • 20
  • It's correct @Helix123, As you can see in the reference [here](http://fmwww.bc.edu/ec-p/wp545.pdf), [here](http://econweb.umd.edu/~sarzosa/teach/2/Disc2_Cluster_handout.pdf) or through lots of lectures about this in Google, the formulation for IV is not different from the standard. I guess the `vcovHC` just cannot properly handle multipart formulas of the `Formula` class. – Rodrigo Remedio Nov 03 '16 at 11:04
  • 1
    Great! I checked with plm development version 1.6-1 and plm's `vcovHC` and `cl.plm` gives the same results except for the degrees of freedom adjustment performed in `cl.plm` (multiplies vcov by `(M/(M-1))*((N-1)/(N-K))`) which can also be performed by `vcovHC(..., type="sss")`. – Helix123 Nov 08 '16 at 16:40
  • Works! Thank you! – André Nov 09 '16 at 22:50
  • 1
    The official CRAN release (1.6-4) of plm now has that incorporated. – Helix123 Nov 30 '16 at 08:17