3 \title{Mantel Test for Similarity of Two Matrices}
5 mantel.test(m1, m2, nperm = 999, graph = FALSE,
6 alternative = "two.sided", ...)
9 \item{m1}{a numeric matrix giving a measure of pairwise distances,
10 correlations, or similarities among observations.}
11 \item{m2}{a second numeric matrix giving another measure of pairwise
12 distances, correlations, or similarities among observations.}
13 \item{nperm}{the number of times to permute the data.}
14 \item{graph}{a logical indicating whether to produce a summary graph
15 (by default the graph is not plotted).}
16 \item{alternative}{a character string defining the alternative
17 hypothesis: \code{"two.sided"} (default), \code{"less"},
18 \code{"greater"}, or any unambiguous abbreviation of these.}
19 \item{\dots}{further arguments to be passed to \code{plot()} (to add a
20 title, change the axis labels, and so on).}
23 This function computes Mantel's permutation test for similarity of two
24 matrices. It permutes the rows and columns of the two matrices
25 randomly and calculates a \eqn{Z}-statistic.
28 The function calculates a \eqn{Z}-statistic for the Mantel test, equal to
29 the sum of the pairwise product of the lower triangles of the
30 permuted matrices, for each permutation of rows and columns. It
31 compares the permuted distribution with the \eqn{Z}-statistic observed
34 If \code{graph = TRUE}, the functions plots the density estimate of
35 the permutation distribution along with the observed \eqn{Z}-statistic
38 The \code{\dots} argument allows the user to give further options to
39 the \code{plot} function: the title main be changed with \code{main=},
40 the axis labels with \code{xlab =}, and \code{ylab =}, and so on.
43 \item{z.stat}{the \eqn{Z}-statistic (sum of rows*columns of lower
44 triangle) of the data matrices.}
45 \item{p}{\eqn{P}-value (quantile of the observed \eqn{Z}-statistic in
46 the permutation distribution).}
47 \item{alternative}{the alternative hypothesis.}
50 Mantel, N. (1967) The detection of disease clustering and a
51 generalized regression approach. \emph{Cancer Research}, \bold{27},
54 Manly, B. F. J. (1986) \emph{Multivariate statistical methods: a primer.}
55 London: Chapman & Hall.
58 Original code in S by Ben Bolker, ported to \R by Julien Claude
61 q1 <- matrix(runif(36), nrow = 6)
62 q2 <- matrix(runif(36), nrow = 6)
63 mantel.test(q1, q2, graph = TRUE,
64 main = "Mantel test: a random example with 6 X 6 matrices",
65 xlab = "z-statistic", ylab = "Density",
66 sub = "The vertical line shows the observed z-statistic")
68 \keyword{multivariate}