# moranIdx: Computes Moran's index for a variable In adephylo: Exploratory Analyses for the Phylogenetic Comparative Method

## Description

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

## Usage

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

## Arguments

 `x` a numeric vector whose autocorrelation is computed. `prox` 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. `addInfo` 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.

## Value

The numeric value of Moran's index.

## Author(s)

Thibaut Jombart tjombart@imperial.ac.uk

## References

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.

`proxTips` which computes phylogenetic proximities between tips of a phylogeny.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29``` ```## Not run: ## use maples dataset data(maples) 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) # right-tail p-value pval 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, col="red", lwd=3) ## End(Not run) ```