Moran.I {ape} | R Documentation |
Computes Moran's I autocorrelation index of a given vector x
according to a distance weights matrix dist
using the method
described by Gittleman and Kot (1990).
Moran.I(x, dist, scaled = FALSE)
x |
a numeric vector. |
dist |
a distance weigths matrix. |
scaled |
logical, indicate whether the index should be scaled to
allow comparisons between indices (default to FALSE ). |
The dist
matrix is used as distance weights, and Moran's I indice
is computed using the formula:
I = n/S0 * (sum{i=1..n} sum{j=1..n} wij(yi - ym))(yj - ym) / (sum{i=1..n} (yi - ym)^2)
with
sum_{i=1..n} sum{j=1..n} wij
The value of I may be evaluated under two null hypotheses, normality and randomization. Only the randomization hypothesis is implemented for now.
A list containing the attributes:
observed |
Moran's I index of x . |
expected |
Expected value of I under the null hypothesis. |
sd |
The standard deviation of I under the null hypothesis. |
p.value |
The p-value of having the observed value under the null hypothesis. |
Julien Dutheil julien.dutheil@univ-montp2.fr
Gittleman, J. L. and M. Kot (1990) Adaptation: statistics and a null model for estimating phylogenetic effects. Systematic Zoology, 39, 227–241.
dist.phylo
, discrete.dist
, dist.taxo
### This will draw the correlogram from Gittleman and Kot 1990 ### This is only for example, consider function plot.correlogram() to draw correlograms. library(ape) data(carnivora) attach(carnivora) # Compute distance matrix for each taxonomic level: dG <- dist.taxo(Genus) dF <- dist.taxo(Family) dSF <- dist.taxo(SuperFamily) dO <- dist.taxo(Order) # We draw the correlogram of average body weights, # with log10-transformed variable: IG <- Moran.I(log10(SW), dG , scale=TRUE) IF <- Moran.I(log10(SW), dF & !dG , scale=TRUE) ISF <- Moran.I(log10(SW), dSF & !dF , scale=TRUE) IO <- Moran.I(log10(SW), dO & !dSF, scale=TRUE) # All Moran's I indices: i <- c(IG$obs, IF$obs, ISF$obs, IO$obs) # With their corresponding p-values: p <- c(IG$p.v, IF$p.v, ISF$p.v, IO$p.v) # Here's the legend: l <- c("G", "F", "SF", "O") # Draw the correlogram (using lattice library): library(lattice) # New Black & White device: trellis.device(device=X11, new=FALSE, color=FALSE) # Black circles are significant at the 5 pch <- ifelse(p < 0.05, 19, 21) # Plot it! xyplot(i~ordered(l,levels=l), type="b", xlab="Rank", ylab="I / Imax", lty=2, lwd=2, cex=1.5, pch=pch, ylim=c(-0.75,0.75))