[R] Help needed on calculation of Moran's I
Geertje Van der Heijden
g.m.f.vanderheijden04 at leeds.ac.uk
Fri Oct 26 17:24:02 CEST 2007
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: g.m.f.vanderheijden04 at leeds.ac.uk
-----Original Message-----
From: Thibaut Jombart [mailto:jombart at biomserv.univ-lyon1.fr]
Sent: 26 October 2007 15:49
To: Geertje Van der Heijden
Cc: r-help at stat.math.ethz.ch
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
jombart at biomserv.univ-lyon1.fr
http://lbbe.univ-lyon1.fr/-Jombart-Thibaut-.html?lang=en
http://pbil.univ-lyon1.fr/software/adegenet/
More information about the R-help
mailing list