How can I obtain robust standard errors for a spatial IV regression in R using the sphet package?

74 views Asked by At

I am running a spatial error model in R using the sphet package with spatial weights. The function I am using is spreg().

Something that is confusing me is the validity of standard errors generated from the approach. Currently, my approach is:

model <- spreg(formula=formula, data=data, listw=listw, endog=~x1, instruments=~z1, model="error")

summary(model1) provides me with coefficient estimates and standard errors. However, I am uncertain about the standard errors because spreg() takes in the argument HAC, which produces a HAC estimator, presumably to account for spatial autocorrelation between observations.

So I'm trying an alternative model:

model1 <- spreg(formula=formula, data=data, listw=listw, endog=~x1, instruments=~z1, model="ivhac", HAC=TRUE)

This code results in an error, Rstudio produces an error message informing me that for HAC to be set to true, the model must be one of "ivhac" or "ols". This error message is produced even though I am using "ivhac" (or "ols", I have tried both).

Further, I have attempted to reproduce the same error with the columbus dataset (from spData) to see if I can understand where it is coming from. Running a similar regression here produces the following error:

spreg(CRIME ~ INC + HOVAL, data=col, listw=col.listw, endog=~HOVAL, instruments=~OPEN, HAC=TRUE, model="ivhac") Error in laghac(formula = formula, data = data, listw = listw, listw2 = listw2, : No distance measure specified

So I am thinking I need to specify a distance measure. But I am again having trouble understanding here, because I am unsure of what this is. sphet has a function to produce a distance measure, read.gwt2dist(). But here, when I run the example code in the documentation, I get the following error:

library(spdep)
data(columbus)
dist <- read.gwt2dist(file = system.file('extdata/knn10columbus.GWT', package = "sphet"), region.id = columbus$POLYID)

Warning message:
In read.gwt2dist(file = system.file("extdata/knn10columbus.GWT",  :
  region.id not named POLYID

I am unsure how to approach the problem from here to obtain robust standard errors using this package.

0

There are 0 answers