mantel.correlog | R Documentation |
mantel.correlog
is the function to calculate a Mantel (cross-)correlogram. The function requires two (or three) matrices.
mantel.correlog( dmat, zmat, wmat = NULL, increment, resamp = 999, quiet = FALSE )
dmat |
a matrix representing distance. |
zmat |
a matrix representing similarity. |
wmat |
an optional third matrix of similarities to calculate a Mantel cross-correlograms. |
increment |
increment for the uniformly distributed distance classes. |
resamp |
the number of permutations under the null to assess level of significance. |
quiet |
If TRUE, the counter is suppressed during execution. |
The function calculates Mantel (cross-)correlograms at discrete distance classes from two (or three) matrixes. The first is the matrix of distances and the second is a matrix of similarities. The optional third matrix is an additional similarity matrix to be used to calculate a Mantel cross-correlogram. Missing values are allowed – values are assumed missing at random.
An object of class "correlog" is returned, consisting of the following components:
correlation |
the value for the Moran (or Mantel) similarity. |
mean.of.class |
the actual average of the distances within each distance class. |
nlok |
the number of pairs within each distance class. |
x.intercept |
the interpolate x.intercept of Epperson (1993). |
p |
the permutation two-sided p-value for each distance-class. |
corr0 |
If a cross-correlogram is calculated, corr0 gives the empirical cross-correlation at distance zero. |
Ottar N. Bjornstad onb1@psu.edu
plot.correlog
# first generate some sample data x <- expand.grid(1:20, 1:5)[, 1] y <- expand.grid(1:20, 1:5)[, 2] # z data from an exponential random field z <- cbind( rmvn.spa(x = x, y = y, p = 2, method = "exp"), rmvn.spa(x = x, y = y, p = 2, method = "exp") ) # w data from a gaussian random field w <- cbind(rmvn.spa( x = x, y = y, p = 2, method = "gaus"), rmvn.spa(x = x, y = y, p = 2, method = "gaus") ) # Make distance and similarity matrices zmat <- cor(t(z)) wmat <- cor(t(w)) dmat <- sqrt(outer(x, x, "-")^2 + outer(y, y, "-")^2) # Mantel correlogram fit1 <- mantel.correlog(dmat = dmat, zmat = zmat, increment = 2, quiet = TRUE, resamp = 0) ## Not run: plot(fit1) # Mantel cross-correlogram fit2 <- mantel.correlog(dmat = dmat, zmat = zmat, wmat = wmat, increment = 2, quiet = TRUE, resamp = 0) ## Not run: plot(fit2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.