[R] troubles performing Moran.I test

Barbara.Spillmann at agrar.uni-giessen.de Barbara.Spillmann at agrar.uni-giessen.de
Wed Jan 7 19:56:07 CET 2009


dear R users,

I have troubles performing Moran.I test as suggested on  
http://www.ats.ucla.edu/stat/r/faq/morans_i.htm

my spatial data are longitude and lattitide of communities. The  
calculation of the inverse distance matrix according to the homepage  
(using my data)

datAL <- read.csv2("C:\\Konvergenz AL.csv", header=T)

ALdist <- as.matrix(dist(cbind(datAL$Länge, datAL$Breite)))
ALdist.inv <- 1/ALdist
for (i in 1:dim(ALdist)[1]){ALdist.inv[i,i]=0}

seems to work since the first 10 elements of my matrix look like this:

            1          2          3          4          5
1 0.00000000 0.06201737 0.06041221 0.03386427 0.05198752
2 0.06201737 0.00000000 0.19611614 0.03562352 0.02964346
3 0.06041221 0.19611614 0.00000000 0.03028913 0.03118914
4 0.03386427 0.03562352 0.03028913 0.00000000 0.02138823
5 0.05198752 0.02964346 0.03118914 0.02138823 0.00000000


the data which might be spatially autocorrelated is LN(Unem05/Unem98,  
the LN of the development in unemployment rates in the communities  
between 1998 and 2005. The first 5 elements of this vector are as  
follows:

Comm    LN(Unem05/Unem98)
1       0.21
2       0.08
3       0.22
4       0.05
5      -0.22

I have 426 communities in total and I don's see what might be wrong  
with the data...However, I have some NAs in there...
when I try to perform the test using:

Moran.I(datAL$LN.Rt05.Rt98., ALdist.inv, na.rm=TRUE)

I get the following error message:
Fehler in if (obs <= ei) 2 * pv else 2 * (1 - pv) :
   Fehlender Wert, wo TRUE/FALSE nötig ist

in english something like
error in if (obs <= ei) 2 * pv else 2 * (1 - pv) :
   missing value, where TRUE/FALSE is needed

can anyone give me a hint what is going wrong??

many thanks in advance!!

Barbara




More information about the R-help mailing list