Hi, Thanks for your help, Thibaut. It was helpful to look at the graphs.
I think that the problem is that when the lower boundary is 0 and the upper boundary is arbitrarily high it takes all connections into account (which shouldn't be a problem right?). If I make the lower boundary slightly higher than 0 and keep the maximum on some random high value or decrease the upper boundary - i.e. not all possible links are taken into account - the lm.morantest does work, but the Moran's I value is still really close to the expected value. I have 58 sites from across the Neotropics. I am looking at the relationship of environmental and biogeographical factors on species richness and would like to see if there is still a spatial pattern in my data when these variables are taken into account. As far as I understand I should take all possible interactions between the sites into account if I want to test the residuals for spatial autocorrelation, right? I am a novice in this kind of spatial analyses, but is there a possibility to take all possible links between one point and all other points in the dataset into account when dealing with the Moran's I test for spatial autocorrelation in your residuals or have I misinterpreted the working of Morna's I? Or is there a better way to calculate it then I have done so far? Any help on this will be greatly appreciated! Many thanks, Geertje ~~~~ Geertje van der Heijden PhD student Tropical Ecology School of Geography University of Leeds Leeds LS2 9JT Tel: (+44)(0)113 3433345 Email: [EMAIL PROTECTED] -----Original Message----- From: Thibaut Jombart [mailto:[EMAIL PROTECTED] Sent: 26 October 2007 15:49 To: Geertje Van der Heijden Cc: [EMAIL PROTECTED] Subject: Re: [R] Help needed on calculation of Moran's I Geertje Van der Heijden wrote: >Hi, > >I am trying to calculate Moran's I test for the residuals for a >regression equation, but I have trouble converting my coordinates into >nb format. > >I have used the dnearneigh() funtion now with an arbitrarily high upper >distance to make it include all plots. However, when I do the >lm.morantest() I get a Moran's I value which is the same as the >expected value and a P-value of 1. > >I have used the following code: > > >>attach(lowland) >>coords <- as.matrix(cbind(long, $lat)) coord.nb <- dnearneigh(coords, >>0, 10000 longlat=TRUE) coord.list <- nb2listw(coord.nb, style="W") >>lianasp.lm <- lm(lianasprich ~ log(averdist) + dsl + lianadens + >> >> >wooddens) > > >>lm.morantest(lianasp.lm, coord.list, alternative="two.sided") >> >> > >And get the following result > > Global Moran's I for regression residuals > >data: >model: lm(formula = lianasprich ~ log(averdist) + dsl + lianadens + >wooddens) >weights: coord.list > >Moran I statistic standard deviate = 0, p-value = 1 alternative >hypothesis: two.sided sample estimates: >Observed Moran's I Expectation Variance > -1.754386e-02 -1.754386e-02 2.125706e-16 > >Can anyone tell me where I went wrong or if there is another way to >generate a nb list? > >Many thanks, >Geertje > > Hi, did you have a look at the graph you produced (using plot.nb)? Maybe the maximum distance between any two neighbours is too high. What does max(dist(coords)) say ? Anyway, there are many different connection networks available in several R packages, some being more appropriate than others to model paticular spatial distributions. The package adegenet proposes a small tool to choose among several graphs interactively: library(adegenet) xy = matrix(runif(100),ncol=2) yourcn = chooseCN(xy) Regards, Thibaut. -- ###################################### Thibaut JOMBART CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive Universite Lyon 1 43 bd du 11 novembre 1918 69622 Villeurbanne Cedex Tél. : 04.72.43.29.35 Fax : 04.72.43.13.88 [EMAIL PROTECTED] http://lbbe.univ-lyon1.fr/-Jombart-Thibaut-.html?lang=en http://pbil.univ-lyon1.fr/software/adegenet/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.