[R-sig-Geo] about "moran's I test"?
Roger Bivand
Roger.Bivand at nhh.no
Wed Feb 7 08:40:05 CET 2007
On Wed, 7 Feb 2007, Zhang Jian wrote:
> I want to do "moran's I test" in R language. I try to use "gearymoran" in
> Package "ade4","moran" in Package "spdep", and Moran.I in Package "ape". But
> I do not know how to do it because data format is different.
Please state clearly what the points are - are they point entities, ot
points representing areal entities? Your choice of measures of contiguity,
which are essential for the use of Moran's I, will depend on this choice.
In addition, the points seem to be along a narrow band (river, road?).
My advice on R-help, given your phrasing, was that the correlog function
in Ottar Bjørnstad's off-CRAN ncf package looks appropriate:
t1 <- read.table("zj1.txt", header=TRUE)
# to read your data as given in your mail (very few observations indeed)
str(t1)
install.packages("ncf",contriburl="http://asi23.ent.psu.edu/onb1/R/src")
# this for Linux/Mac, Windows is
# install.packages("ncf",contriburl="http://asi23.ent.psu.edu/onb1/R/windows")
library(ncf)
summary(dist(as.matrix(t1[,1:2])))
# to find appropriate distance increments
res <- correlog(t1$x, t1$y, t1$dbh, increment=25)
str(res)
plot(res)
However, this is largely without meaning unless you have some motivated
understanding of how or why the observations are showing similar values in
space. The correlog() function takes the whole data range, which is most
likely totally inappropriate if you know that influence drops off quickly.
In any case, without taking background variables into account, you may
"find" autocorrelation when in fact there are spatially patterned missing
variables.
Hope this helps,
Roger
>
> My data:
>
> x y dbh
>
> 111.03 10.7 7
>
> 118.11 0.28 1.2
>
> 165.36 0.36 8.4
>
> 282.9 0.3 7.5
>
> 303.29 13.32 12.2
>
> 319.28 3.88 6.2
>
> 447 9 6
>
> 445.5 18.3 13.8
>
> 445.5 12.1 7.1
>
> 467.64 1.2 4.7
>
> 485.4 14.1 4.4
>
> 2.98 23.95 11.7
>
> 15 35.78 23.5
>
> 130.21 23.6 14.1
>
> 213.5 23.22 21.5
>
> 233.57 28.76 35.4
>
> 482.3 20.5 6
>
> 69.73 45.21 7.5
>
> 69.8 50.49 10.2
>
> 76.65 45.5 21.5
>
>
>
> "x","y" are spatial coordinate;
>
> "dbh" is variable
>
> I want to test the spatial autocorrelation of "dbh" in different distances
> by "x" and "y".
>
>
>
> Thanks,
>
> Jian Zhang
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at 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.Bivand at nhh.no
More information about the R-sig-Geo
mailing list