Skip to contents

With the edge-corrected space-time K estimates of SpaceTimeK, the statistic is \(T = \sum_{s,t} (K_{st}(s, t) - K_s(s) K_t(t))\), zero in expectation when space and time are independent; its null distribution comes from permuting the event times over the fixed locations, as splancs::stmctest (Diggle et al. 1995). p-value (1 + number of simulated T >= observed T) / (nsim + 1). Permutations are Fisher-Yates shuffles from Philox stream k of seed, identical to the Python arm (splancs uses sample). Pairs count at distance <= s and <= t in every bin; splancs drops pairs exactly at the largest s or t, so the two differ only when a pair distance ties a top grid value.

Usage

SpaceTimeInteractionTest(
  points,
  times,
  s,
  t,
  window,
  tlimits,
  nsim = 99L,
  seed = 1L
)

Arguments

points

Two-column matrix of coordinates.

times

Event times.

s

Spatial distances.

t

Temporal distances.

window

c(xmin, xmax, ymin, ymax).

tlimits

c(tmin, tmax).

nsim

Number of permutations.

seed

Philox seed.

Value

List with statistic, p_value, simulated, nsim.

References

Diggle, P. J., Chetwynd, A. G., Haggkvist, R. and Morris, S. E. (1995). Second-order analysis of space-time clustering. Statistical Methods in Medical Research 4, 124-136.

Examples

P <- cbind(c(.1, .4, .35, .8, .7, .55, .2, .9, .15, .6), c(.2, .8, .3, .6, .15, .5, .65, .9,
  .95, .85))
tm <- c(1, 7, 2, 5, 3, 4.5, 6, 9, 8, 8.5)
SpaceTimeInteractionTest(P, tm, c(.2, .4), c(2.3, 4.3), c(0, 1, 0, 1), c(0, 10),
  nsim = 19)$p_value
#> [1] 0.05