Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

moranIdx

Computes Moran's index for a variable


Description

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

Usage

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.

See Also

proxTips which computes phylogenetic proximities between tips of a phylogeny.

Examples

## 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[1]) # 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[1], col="red", lwd=3)


## End(Not run)

adephylo

Exploratory Analyses for the Phylogenetic Comparative Method

v1.1-11
GPL (>= 2)
Authors
Thibaut Jombart <t.jombart@imperial.ac.uk>, Stéphane Dray <stephane.dray@univ-lyon1.fr>, Anders Ellern Bilgrau <abilgrau@math.aau.dk>
Initial release
2017-12-18

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.