mantst
Mantel’s space-time test
mantst( x, y = NULL, t, cs = 0, ct = 0, nsim = 999, seed = NULL, metric = "euclid", lonlat = FALSE)The Pearson correlation, over all pairs of events, between their
spatial dissimilarity (the distance, or 1 / (distance + cs) when
cs > 0, Mantel’s reciprocal transform) and their temporal one
(|t_i - t_j|, or 1 / (|t_i - t_j| + ct)), with a permutation test
that permutes the times over the fixed locations (Mantel 1967). Drawing
distances and intervals independently instead, as some descriptions do,
does not keep the dependence among the pairs of one distance matrix and
gives no test of stated size. Memory grows with the number of events,
not pairs; time with pairs times permutations.
Parameters
Section titled “Parameters”x, yThe points:
xandynumeric vectors of equal length; orxa matrix or data frame with columns namedxandy(orXandY, assf::st_coordinates()names them, orlonandlatwithlonlat = TRUE) andyNULL; orxan sf or sfc object of POINT geometries, whose coordinate reference system must agree withlonlat. An unnamed two-column matrix is read asxtheny; other columns are never taken by position. Vectors given separately (x,y, andwortwhere a function takes them) are matched by name when every one is named and no name repeats, as elsewhere in the package; otherwise by position. No missing or infinite values.tThe time of each event: finite numbers (for dates,
as.numeric()of them, in days or seconds).cs, ctThe constants of the reciprocal transforms: numbers from 0 (0 uses the raw distance or interval).
nsimThe number of permutations: one whole number from 0.
seedNULLto draw the simulations’ seed from R’s generator (soset.seed()fixes them), or one whole number from 0.metricThe spatial distance:
"euclid"or"manhattan"; the test permutes times and needs no expectation, so both are exact.lonlatFALSE(the default) whenxandyare planar coordinates in one length unit;TRUEwhen they are longitude and latitude in degrees, which are then projected to metres byeqproj()about their own centre, and centres are returned in degrees. It is never guessed.
Returns
Section titled “Returns”A named numeric vector: r (the correlation), pairs, and the
permutation p-values pup ((1 + #{r_perm >= r}) / (nsim + 1), large
r: events close in space are close in time when both are raw
distances), plo (r_perm <= r) and p2 (|r_perm| >= |r|); NaN
without permutations. 3 to 46340 events.
References
Section titled “References”Mantel, N. (1967). The detection of disease clustering and a generalized regression approach. Cancer Research, 27(2), 209-220.
Examples
Section titled “Examples”set.seed(1)x <- runif(60)y <- runif(60)mantst(x, y, t = x + rnorm(60, sd = 0.1), nsim = 199, seed = 1)Generated from the R help page: mantst in the R reference.