`stK.Rd`

The function `stKtest`

wraps functions in package splancs to
perform the K-function based Monte Carlo permutation test for space-time
clustering (Diggle et al, 1995) for `"epidataCS"`

.
The implementation is due to Meyer et al. (2016).

```
stKtest(object, eps.s = NULL, eps.t = NULL, B = 199,
cores = 1, seed = NULL, poly = object$W)
# S3 method for stKtest
plot(x, which = c("D", "R", "MC"),
args.D = list(), args.D0 = args.D, args.R = list(), args.MC = list(),
mfrow = sort(n2mfrow(length(which))), ...)
```

- object
an object of class

`"epidataCS"`

.- eps.s, eps.t
numeric vectors defining the spatial and temporal grids of critical distances over which to evaluate the test. The default (

`NULL`

) uses equidistant values from 0 to the smallest`eps.s`

/`eps.t`

value in`object$events`

, but not larger than half the observed spatial/temporal domain.- B
the number of permutations.

- cores
the number of parallel processes over which to distribute the requested number of permutations.

- seed
argument for

`set.seed`

to initialize the random number generator such that results become reproducible (also if`cores > 1`

, see`plapply`

).- poly
the polygonal observation region of the events (as an object handled by

`xylist`

). The default`object$W`

might not work since package splancs does not support multi-polygons. In this case, the`poly`

argument can be used to specify a substitute.- x
an

`"stKtest"`

.- which
a character vector indicating which diagnostic plots to produce. The full set is

`c("D", "D0", "R", "MC")`

. The special value`which = "stdiagn"`

means to call the associated splancs function`stdiagn`

.- args.D,args.D0,args.R,args.MC
argument lists for the plot functions

`persp`

(for`"D"`

and`"D0"`

),`plot.default`

(`"R"`

), and`truehist`

(`"MC"`

), respectively, to modify the default settings. Ignored if`which = "stdiagn"`

.- mfrow
`par`

-setting to layout the plots. Ignored for`which = "stdiagn"`

and if set to`NULL`

.- ...
ignored (argument of the generic).

an object of class `"stKtest"`

(inheriting from `"htest"`

),
which is a list with the following components:

a character string indicating the type of test performed.

a character string naming the supplied `object`

.

the sum \(U\) of the standardized residuals \(R(s,t)\).

the number `B`

of permutations.

the p-value for the test.

the coordinate matrix of the event locations (for
`stdiagn`

.

the estimated K-function as returned by
`stkhat`

.

the standard error of the estimated \(D(s,t)\) as
returned by `stsecal`

.

the observed and permutation values of the test
statistic as returned by `stmctest`

.

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

Meyer, S., Warnke, I., Rössler, W. and Held, L. (2016):
Model-based testing for space-time interaction using point processes:
An application to psychiatric hospital admissions in an urban area.
*Spatial and Spatio-temporal Epidemiology*, **17**, 15-25.
doi: 10.1016/j.sste.2016.03.002
.
Eprint: https://arxiv.org/abs/1512.09052.

Sebastian Meyer

```
if (requireNamespace("splancs")) {
data("imdepi")
imdepiB <- subset(imdepi, type == "B")
mainpoly <- coordinates(imdepiB$W@polygons[[1]]@Polygons[[5]])
if (surveillance.options("allExamples")) {
SGRID <- c(0, 10, 25, 50, 75, 100, 150, 200)
TGRID <- c(0, 7, 14, 21, 28)
B <- 99
CORES <- 2
} else { # dummy settings for fast CRAN checks
SGRID <- c(0, 50)
TGRID <- c(0, 30)
B <- 9
CORES <- 1
}
imdBstKtest <- stKtest(imdepiB, eps.s = SGRID, eps.t = TGRID, B = B,
cores = CORES, seed = 1, poly = list(mainpoly))
print(imdBstKtest)
plot(imdBstKtest)
}
```