[R-sig-Geo] Clustering Sd Error in Spatial Models.

Roger Bivand Roger@Biv@nd @ending from nhh@no
Thu Oct 11 10:10:33 CEST 2018


On Tue, 9 Oct 2018, Amir Neto wrote:

> Hello,
>
> I am currently working on a project estimating a spatial panel model.
> Because I also estimate non-spatial models I am computing the clustered
> standard errors following Stock and Watson (2008).
>
> I tried to do the same for my spatial models however I am running into the
> some errors (depending if I bootstrap or not my clustered
> variance-covariance matrix). Below is a reproducible example.

Although it would be desirable that spatial models matched the 
lmtest/sandwich framework better, are Conway standard errors an 
alternative? See this interesting blog post correcting an implementation:

https://darinchristensen.com/post/2017-08-21-correction/
https://darinchristensen.com/post/2015-08-30-conley/

https://github.com/darinchristensen/conley-sehttps://github.com/darinchristensen/conley-se

Hope this helps,

Roger

>
>
> #### Example
>> data(Produc, package = "plm")
>> data(usaww)
>>
>> fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
>>
>> fespaterr <- spml(fm, data = Produc, listw = mat2listw(usaww),
> +                   model="within", spatial.error="kkp")
>>
>> library(lmtest)
>> library(sandwich)
>>
>> vcov_test <- vcov_test <- vcovCL(fespaterr, cluster = Produc$state)
> Error in UseMethod("estfun") :
>  no applicable method for 'estfun' applied to an object of class "splm"
>
>> vcov_boot <- vcovBS(fespaterr, cluster = Produc$state, R=250)
> Error in terms.default(x) : no terms component nor attribute
> Error in terms.default(x) : no terms component nor attribute
> Error in terms.default(x) : no terms component nor attributebute
>
> #############
> ### Non spatial
> library(lfe)
>
> fe_cluster <- felm(log(gsp) ~ log(pcap) + log(pc) + log(emp) +
> unemp|year+state|0|state,data=Produc)
>
>> summary(fe)
>
> Call:
>   felm(formula = log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp |
> year + state | 0 | state, data = Produc)
>
> Residuals:
>      Min        1Q    Median        3Q       Max
> -0.160369 -0.018026 -0.000859  0.016745  0.170752
>
> Coefficients:
>           Estimate Cluster s.e. t value Pr(>|t|)
> log(pcap) -0.030176     0.060042  -0.503   0.6154
> log(pc)    0.168828     0.088331   1.911   0.0563 .
> log(emp)   0.769306     0.087700   8.772   <2e-16 ***
> unemp     -0.004221     0.003294  -1.281   0.2005
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> ##########
>
> My questions are:
> 1) Is it possible to cluster the variance-covariance matrix on spatial
> models?
> 2) If so, what is the correct procedure?
>
>
> Thank you for your help,
> Amir
> --
> Amir B Ferreira Neto
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en


More information about the R-sig-Geo mailing list