On Thu, 14 Oct 2010, Angela Parenti wrote:
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?
By "pooled", do you mean an NxT by NxT matrix? Is your data
spatio-temporal in that case? How large is N, and how large T? Did your
IDW procedure induce "spatial" relations above and below the block
diagonal, or do you just need T replicated N by N weights matrices down
the block diagonal? You may have a result from IDW, but is it what you
think it is - should d_{itjt} == d_{itj(t-1)} == d_{itj(t+1)} and so on?
To create a contiguity matrix, you can use graph-based methods listed
under ?graph2nb or contiguity using ?poly2nb, for which you do need the
boundaries of your regions as for example a shapefile.
Roger
Thank you in advance,
Angela Parenti
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo