moran: Computes Moran's I correlation index

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/moran.R

Description

Natively built for computing Moran's I on dgCMatrix objects, this routine allows computing the I on large sparse matrices (graphs), feature that is not supported on ape::Moran.I.

Usage

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

Arguments

x

Numeric vector of size n.

w

Numeric matrix of size n * n. Weights. It can be either a object of class matrix or dgCMatrix from the Matrix package.

normalize.w

Logical scalar. When TRUE normalizes rowsums to one (or zero).

Value

Numeric scalar with Moran's I.

Author(s)

George G. Vega Yon

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%27s_I&oldid=679297766

See Also

Other statistics: classify_adopters, cumulative_adopt_count, dgr, ego_variance, exposure, hazard_rate, infection, struct_equiv, threshold, vertex_covariate_dist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
# Generating a small random graph
set.seed(123)
graph <- rgraph_ba(t = 4)
w <- igraph::distances(igraph::graph_from_adjacency_matrix(graph))
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)

## End(Not run)

netdiffuseR documentation built on May 19, 2017, 6:39 p.m.

Search within the netdiffuseR package
Search all R packages, documentation and source code