Learn R Programming

surveillance (version 1.20.3)

knox: Knox Test for Space-Time Interaction

Description

Given temporal and spatial distances as well as corresponding critical thresholds defining what “close” means, the function knox performs Knox (1963, 1964) test for space-time interaction. The corresponding p-value can be calculated either by the Poisson approximation or by a Monte Carlo permutation approach (Mantel, 1967) with support for parallel computation via plapply. There is a simple plot-method showing a truehist of the simulated null distribution together with the expected and observed values. This implementation of the Knox test is due to Meyer et al. (2016).

Usage

knox(dt, ds, eps.t, eps.s, simulate.p.value = TRUE, B = 999, ...)

# S3 method for knox plot(x, ...)

Value

an object of class "knox" (inheriting from "htest"), which is a list with the following components:

method

a character string indicating the type of test performed, and whether the Poisson approximation or Monte Carlo simulation was used.

data.name

a character string giving the supplied dt and ds arguments.

statistic

the number of close pairs.

parameter

if simulate.p.value = TRUE, the number B of permutations, otherwise the lambda parameter of the Poisson distribution, i.e., the same as null.value.

p.value

the p-value for the test. In case simulate.p.value = TRUE, the p-value from the Poisson approximation is still attached as an attribute "Poisson".

alternative

the character string "greater" (this is a one-sided test).

null.value

the expected number of close pairs in the absence of space-time interaction.

table

the contingency table of dt <= eps.t and ds <= eps.s.

The plot-method invisibly returns NULL.

A toLatex-method exists, which generates LaTeX code for the contingency table associated with the Knox test.

Arguments

dt,ds

numeric vectors containing temporal and spatial distances, respectively. Logical vectors indicating temporal/spatial closeness may also be supplied, in which case eps.t/eps.s is ignored. To test for space-time interaction in a single point pattern of \(n\) events, these vectors should be of length \(n*(n-1)/2\) and contain the pairwise event distances (e.g., the lower triangle of the distance matrix, such as in "dist" objects). Note that there is no special handling of matrix input, i.e., if dt or ds are matrices, all elements are used (but a warning is given if a symmetric matrix is detected).

eps.t,eps.s

Critical distances defining closeness in time and space, respectively. Distances lower than or equal to the critical distance are considered “"close"”.

simulate.p.value

logical indicating if a Monte Carlo permutation test should be performed (as per default). Do not forget to set the .Random.seed via an extra .seed argument if reproducibility is required (see the ... arguments below). If simulate.p.value = FALSE, the Poisson approximation is used (but see the note below).

B

number of permutations for the Monte Carlo approach.

...

arguments configuring plapply: .parallel, .seed, and .verbose. By default, no parallelization is performed (.parallel = 1), and a progress bar is shown (.verbose = TRUE).
For the plot-method, further arguments passed to truehist.

x

an object of class "knox" as returned by the knox test.

Author

Sebastian Meyer

References

Knox, G. (1963): Detection of low intensity epidemicity: application to cleft lip and palate. British Journal of Preventive & Social Medicine, 17, 121-127.

Knox, E. G. (1964): The detection of space-time interactions. Journal of the Royal Statistical Society. Series C (Applied Statistics), 13, 25-30.

Kulldorff, M. and Hjalmars, U. (1999): The Knox method and other tests for space-time interaction. Biometrics, 55, 544-552.

Mantel, N. (1967): The detection of disease clustering and a generalized regression approach. Cancer Research, 27, 209-220.

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. tools:::Rd_expr_doi("10.1016/j.sste.2016.03.002"). Eprint: https://arxiv.org/abs/1512.09052.

See Also

The function mantel.randtest in package ade4 implements Mantel's (1967) space-time interaction test, i.e., using the Pearson correlation between the spatial and temporal distances of all event pairs as the test statistic, and assessing statistical significance using a Monte Carlo permutation approach as with simulate.p.value here in the knox function. To combine information from different scales eps.t and eps.s while also handling edge effects, the space-time K-function test available via stKtest can be used. Function epitest tests epidemicity in a "twinstim" point process model.

Examples

Run this code
data("imdepi")
imdepiB <- subset(imdepi, type == "B")

## Perfom the Knox test using the Poisson approximation
knoxtest <- knox(
    dt = dist(imdepiB$events$time), eps.t = 30,
    ds = dist(coordinates(imdepiB$events)), eps.s = 50,
    simulate.p.value = FALSE
)
knoxtest
## The Poisson approximation works well for these data since
## the proportion of close pairs is rather small (204/56280).

## contingency table in LaTeX
toLatex(knoxtest)


## Obtain the p-value via a Monte Carlo permutation test,
## where the permutations can be computed in parallel
## (using forking on Unix-alikes and a cluster on Windows, see ?plapply)
knoxtestMC <- knox(
    dt = dist(imdepiB$events$time), eps.t = 30,
    ds = dist(coordinates(imdepiB$events)), eps.s = 50,
    simulate.p.value = TRUE, B = 99,  # limited here for speed
    .parallel = 2, .seed = 1, .verbose = FALSE
)
knoxtestMC
plot(knoxtestMC)

Run the code above in your browser using DataLab