Learn R Programming

netdiffuseR (version 1.16.2)

moran: Computes Moran's I correlation index

Description

Computes Moran's I correlation index

Usage

moran(x, w, normalize.w = TRUE)

Arguments

x
Numeric vector of size $n$.
w
Numeric matrix of size $n\times n$. Weights.
normalize.w
Logical scalar. When TRUE normalizes rowsums to one (or zero).

Value

  • Numeric scalar with Moran's I.

References

Moran's I. (2015, September 3). In Wikipedia, The Free Encyclopedia. Retrieved 06:23, December 22, 2015, from https://en.wikipedia.org/w/index.php?title=Moran

See Also

Other statistics: cumulative_adopt_count, dgr, exposure, hazard_rate, infection, struct_equiv, threshold

Examples

Run this code
# Generating a small random graph
set.seed(123)
graph <- rgraph_ba(t = 4)
w <- sna::geodist(as.matrix(w))
x <- rnorm(5)

# Computing Moran's I
moran(x, w)

# Comparing with the ape's package version
moran(x, w/rowSums(as.array(w)))
ape::Moran.I(x, w)

Run the code above in your browser using DataLab