moran.idx {adephylo}R Documentation

Computes Moran's index for a variable


This simple function computes Moran's index of autocorrelation given a variable and a matrix of proximities among observations.


moran.idx(x, prox, addInfo = FALSE)



a numeric vector whose autocorrelation is computed.


a matrix of proximities between observations, as computed by the proxTips. Off-diagonal terms must be positive or null, while diagonal terms must all equal zero.


a logical indicating whether supplementary info (null value, minimum and maximum values) should be returned (TRUE) or not (FALSE, default); if computed, these quantities are returned as attributes.


The numeric value of Moran's index.


Thibaut Jombart


Moran, P.A.P. (1948) The interpretation of statistical maps. Journal of the Royal Statistical Society, B 10, 243–251.

Moran, P.A.P. (1950) Notes on continuous stochastic phenomena. Biometrika, 37, 17–23.

de Jong, P. and Sprenger, C. and van Veen, F. (1984) On extreme values of Moran's I and Geary's c. Geographical Analysis, 16, 17–24.

See Also

proxTips which computes phylogenetic proximities between tips of a phylogeny.


## Not run: 
## use maples dataset
tre <- read.tree(text=maples$tre)
dom <- maples$tab$Dom
bif <- maples$tab$Bif

## get a proximity matrix between tips 
W <- proxTips(tre, met="Abouheif")

## compute Moran's I for two traits (dom and bif)
moran.idx(dom, W)
moran.idx(bif, W)
moran.idx(rnorm(nTips(tre)), W)

## build a simple permutation test for 'bif'
sim <- replicate(499, moran.idx(sample(bif), W)) # permutations
sim <- c(moran.idx(bif, W), sim)

pval <- mean(sim>=sim[1]) # right-tail p-value

hist(sim, col="grey", main="Moran's I Monte Carlo test for 'bif'") # plot
mtext("Histogram of permutations and observation (in red)")
abline(v=sim[1], col="red", lwd=3)

## End(Not run)

[Package adephylo version 1.1-11 Index]