[R] how to define w matrix in my case?

Xu Yuan greenboy21 at gmail.com
Tue Dec 12 06:53:25 CET 2006


hello list,

I have N agricultural fields (some of them share borders, some don't)
with ph as the variable of interest. Since I want to test the spatial
autocorrelation, I need to come up with the w matrix. The first and
easy way that came to my brain was the binary relationship, i.e., the
w matrix is all 1s and 0s with 1 meaning two fields sharing border and
0 not. So I checked the distribution of the N fields, and I manually
defined a NxN matrix with 1s and 0s. I list the variable of interest
(ph) as a vector with N elements, and plan to use moran or moran.test
to test the spatial autocorrelation. However, I had difficulty to run
the code. Anyone has suggestions about my case where the areal/lattice
data are irregular?

Please also let me know if moran or moran.test is the correct command to use.

Thanks.
XY




More information about the R-help mailing list