3

I am running spatial panel models (using splm) of census tracts in the U.S. between 1990 and 2010 with neighbor matrices based upon distance or contiguity. But I also want to cluster the standard errors on the city the census tract is within.

Within panel models (plm) there is a way to do this (with the postestimation function "vcovHC" and then "coeftest" (see here)) but I do not see and have not been able to find a way to do this with a splm object. When I run the same code, I receive the error "Error in terms.default(object) : no terms component nor attribute." There are a lot of questions about clustering with other models, but none with the splm package, so any help is greatly appreciated.

This can be done in Stata with the XSLME package and including: vce(cluster "group_var") at the end of the call, but with 37k+ cases over 3 panels, Stata crashes.

A hypothetical example with the same problem is below:

library(splm)
library(spdep)    
data("Insurance")
    data(itaww)
    sw <- mat2listw(itaww)

    myformula <- rgdp ~ agen + school + fam 
    myresults <- spml(myformula,
                      data = Insurance,
                      listw = sw,
                      model = "within",
                      lag = FALSE,
                      effect = "individual",
                      spatial.error = "b")
    summary(myresults)

    results_vcov <- vcovHC(myresults, type = "HC0", cluster = "group")

## same thing but with plm
library(plm)
    myplmresults <- plm(myformula,
                        data = Insurance,
                        model = "within")
    summary(myplmresults)

    results_vcov <- vcovHC(myplmresults, type = "HC0", cluster = "group")
    library(lmtest)
    coeftest(myplmresults, vcov = results_vcov)
bcrew
  • 63
  • 3
  • You might take a look at `multwavcov` and `clusterSE` packages. Neither of them directly mention `splm` support, but if the splm object inherits from lm or a similar object, there is a small chance one of these could work. – lmo Apr 26 '16 at 16:02
  • Good suggestions! Unfortunately multwavcov returns the error "no applicable method for 'estfun' applied to an object of class "splm"" and clusterSE returns the same error as the method I described above. – bcrew Apr 26 '16 at 16:22

0 Answers0