[R-sig-Geo] How to build a spatial weights list for pooled data
Angela Parenti
aparenti at ec.unipi.it
Thu Oct 14 16:14:49 CEST 2010
Hello Roger and everybody else.
I have another question about Weight Matrices. For one of my models I
estimate a pooled regression. Then, in order run the Moran test on the
pooled regression residuals I need to construct a spatial weights list
of the same dimension.
I already found the way for the spatial matrix built on the inverse
distance between neighbours. Here the code for inverse distance matrix:
#####################
# Moran's Test for spatial effects
sampleCentroid.Pooled <-
rbind(samplecentroid.europeReorderedCamEcon,samplecentroid.europeReorderedCamEcon)
eu.regions.nb_pooled <- dnearneigh(sampleCentroid.Pooled[iii,], 0,
max(distanceMatrix), row.names=NULL, longlat=TRUE)
coords_pooled <- sampleCentroid.Pooled[iii,]
dlist_pooled <- nbdists(eu.regions.nb_pooled, coords_pooled, longlat=TRUE)
dlist1_pooled <- lapply(dlist_pooled, function(x) 1/(x^2))
eu.regions.w1_pooled <- nb2listw(eu.regions.nb_pooled,
glist=dlist1_pooled, style="W", zero.policy=TRUE)
moranTestmodelI_w1 <- lm.morantest(modelI,
eu.regions.w1_pooled,zero.policy=TRUE, alternative="two.sided")
print(rbind(c("Global Moran's I for Model I","w1_EK","bivand",""),
c("Observed Moran's I", "EI", "VI", "p-value"),
c(as.numeric(moranTestmodelI_w1$estimate[1]),as.numeric(moranTestmodelI_w1$estimate[2]),
as.numeric(moranTestmodelI_w1$estimate[3]),moranTestmodelI_w1$p.value)
))
######################
Differently, I didn't understand yet how to build a spatial weights list
for pooled data in case of first-order contiguity matrix. Can you help me?
Thank you in advance,
Angela Parenti
More information about the R-sig-Geo
mailing list