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.
Usage
mantst(
x,
y = NULL,
t,
cs = 0,
ct = 0,
nsim = 999,
seed = NULL,
metric = "euclid",
lonlat = FALSE
)Arguments
- x, y
The 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.- t
The time of each event: finite numbers (for dates,
as.numeric()of them, in days or seconds).- cs, ct
The constants of the reciprocal transforms: numbers from 0 (0 uses the raw distance or interval).
- nsim
The number of permutations: one whole number from 0.
- seed
NULLto draw the simulations' seed from R's generator (soset.seed()fixes them), or one whole number from 0.- metric
The spatial distance:
"euclid"or"manhattan"; the test permutes times and needs no expectation, so both are exact.- lonlat
FALSE(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.
Value
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.