# [R] R - Understanding output of the Knoxtest (Package (surveillance))

Oscar Janin oscar.b.janin at gmail.com
Fri Apr 22 09:52:58 CEST 2016

```The function knox of the "Surveillance" package performs Knox test for
space-time interaction. The output is supposed to give the numbers of
events that occur in a specific distance in space and time define by the
function arguments. This function also perform a Monte Carlo permutation
test, which give the estimated value (based on a random distribution) which
are supposed to be compared to the observed value. This comparison gives a
ratio which means the chance that event occur in a specific distance in
time and space.

Here is the example of the function and it's output:

library(surveillance)
>     data("imdepi")
>     imdepiB <- subset(imdepi, type == "B")
>
>     ## 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)
>     knoxtest <- knox(
>       dt = dist(imdepiB\$events\$time), eps.t = 30,
>       ds = dist(coordinates(imdepiB\$events)), eps.s = 50,
>       simulate.p.value = TRUE, B = 19,
>       .parallel = 2, .seed = 1, .verbose = FALSE
>     )
>     knoxtest
>

Output:

Knox test with Poisson approximation
>
>     data:  dt = dist(imdepiB\$events\$time) and ds =
> dist(coordinates(imdepiB\$events))
>     number of close pairs = 204, lambda = 181.57, p-value = 0.04649
>     alternative hypothesis: true number is greater than 181.5686
>
>     contingency table:
>            ds
>     dt      <= 50  > 50
>       <= 30   204  1295
>        > 30  6613 48168
>

The "imdepi" dataset include 636 events, so, the output isn't a count of
the event occuring in a specific distance in space and time. Also, even if
I change the value of "B", which correspond to the number of permutation
for the Monte Carlo approach, the results stays the same.

*What the numbers of output contingency table mean?How the Monte Carlo
iteration influence the results?*

Here are the links to the Knox Test function Description [1] and it's Code
[2].

[1]: http://finzi.psych.upenn.edu/R/library/surveillance/html/knox.html
[2]:
https://r-forge.r-project.org/scm/viewvc.php/pkg/R/knox.R?view=markup&root=surveillance&pathrev=1292