[R] Function stslshac {sphet}: heteroskedasticity and autocorrelation consistent (HAC) estimator
monika nov
monika.novac at gmail.com
Sat Sep 19 22:46:10 CEST 2015
Dear Roger,
Thank you for your email.
I am sorry for HTML containing email. I am not very good in IT so I
didn't know that my email client is using HTML by default. Now I have
tried to turn it off and I would be very grateful if you could let me
know if it is all right now.
Regarding my question. 'if you use a model with semiparametric fitting
of HAC, how might you check that it actually worked'
is not exactly what I wanted to ask. Although answer to this question
would be also helpful.
What I wanted to ask is a bit more specific. I wanted to know, whether
it is a good practice to apply tests for spatial autocorrelation (for
example one of them can be run in R by function moran.test, package
sphet) to residuals from a model obtained by function stslshac
(package spdep). Further I would like to know whether significance of
this test (rejecting the null hypothesis) means, that I should not use
the estimate produced by stslshac function because model is
missspecified. This is maybe more an econometric theory question
rather than R programming question and I am very sorry if I am not
supposed to ask these questions in this forum.
This is quite specific and technical question so I think that the
question may not be understandable for people without econometric
background, even if asked clearly.
I do not think that including an example of code would help to
understand my question, however I am including one bellow.
Thank you for your suggestion about r-sig-geo mailing list, I have
already posted it there.
Best wishes
Monika
####################################################################################################################################
library(sphet)
library(spdep)
data(auckland)
# In the following part objects needed as arguments for stslshac
function are created:
auckland.listw<-nb2listw(auckland.nb, style="W")
coord1 <- cbind(seq(1, nrow(auckland)), auckland$Easting, auckland$Norting)
id1 <- seq(1, nrow(auckland))
tmp <- distance(auckland, region.id = id1, output = TRUE,
type = "NN", nn = 10, shape.name = "shapefile",
region.id.name = "id1",
firstline = TRUE, file.name = "auckland_nn_10.GWT")
coldist <- read.gwt2dist(file = "auckland_nn_10.GWT", region.id = id1,skip = 1)
# Now follows the estimation and printing of summary of results:
AucklandHAC<-(stslshac(Deaths.1977.85~Deaths.1977.85+Easting+Northing,
listw=auckland.listw, type=c("Triangular"),
distance=coldist,data=auckland))
summary(AucklandHAC)
# Now follows an example of the tests I am asking about. I am not sure
whether it is econometrically correct to apply this test for residuals
estiated by stslshac function
moran.test(AucklandHAC$residuals,listw=auckland.listw, alternative="two.sided")
######################################################################################################################
Here are the results I get after running the Moran.test. The test is
significant and the null hypothesis is rejected. I am wondering, can I
still use the stslshac function and its estimate?
Moran's I test under randomisation
data: AucklandHAC$residuals
weights: auckland.listw
Moran I statistic standard deviate = -4.302, p-value = 1.693e-05
alternative hypothesis: two.sided
sample estimates:
Moran I statistic Expectation Variance
-0.230081673 -0.006024096 0.002712539
On 19 September 2015 at 18:48, Roger Bivand <roger.bivand at nhh.no> wrote:
> monika nov <monika.novac <at> gmail.com> writes:
>
>>
>> Dear R-users,
>>
>> I have quite basic question for econometricians, however I would like to be
>> sure in this.
>>
>> If I use a HAC estimator of the variance-covariance (VC) matrix for a
>> spatial econometric model, do I still need to test the residuals for
>> spatial autocorrelation and heteroscedasticity? (in particular I am using
>> function stslshac available in package sphet. The estimator is based on
>> Kelejian, H.H. and Prucha, I.R. (2007) HAC estimation in a spatial
>> framework, Journal of Econometrics, 140, pages 131–154).
>>
>
> Please consider posting on R-sig-geo, since your question concerns spatial
> regression. Roughly, you might mean that if you use a model with
> semiparametric fitting of HAC, how might you check that it actually worked,
> but your meaning isn't obvious. If you include an example using a built-in
> data set, then your intentions would be clearer.
>
> ...
>> I would be grateful for any reaction.
>>
>> Monika
>>
> PS. Please post plain text, not HTML
>
> Roger Bivand
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list