pointpats.knox

pointpats.knox(s_coords, t_coords, delta, tau, permutations=99, debug=False)[source]

Knox test for spatio-temporal interaction. [KB64]

Parameters
s_coordsarray

(n, 2), spatial coordinates.

t_coordsarray

(n, 1), temporal coordinates.

deltafloat

threshold for proximity in space.

taufloat

threshold for proximity in time.

permutationsint, optional

the number of permutations used to establish pseudo- significance (the default is 99).

debugbool, optional

if true, debugging information is printed (the default is False).

Returns
knox_resultdictionary

contains the statistic (stat) for the test and the associated p-value (pvalue).

statfloat

value of the knox test for the dataset.

pvaluefloat

pseudo p-value associated with the statistic.

countsint

count of space time neighbors.

Examples

>>> import numpy as np
>>> import libpysal as lps
>>> from pointpats import SpaceTimeEvents, knox

Read in the example data and create an instance of SpaceTimeEvents.

>>> path = lps.examples.get_path("burkitt.shp")
>>> events = SpaceTimeEvents(path,'T')

Set the random seed generator. This is used by the permutation based inference to replicate the pseudo-significance of our example results - the end-user will normally omit this step.

>>> np.random.seed(100)

Run the Knox test with distance and time thresholds of 20 and 5, respectively. This counts the events that are closer than 20 units in space, and 5 units in time.

>>> result = knox(events.space, events.t, delta=20, tau=5, permutations=99)

Next, we examine the results. First, we call the statistic from the results dictionary. This reports that there are 13 events close in both space and time, according to our threshold definitions.

>>> result['stat'] == 13
True

Next, we look at the pseudo-significance of this value, calculated by permuting the timestamps and rerunning the statistics. In this case, the results indicate there is likely no space-time interaction between the events.

>>> print("%2.2f"%result['pvalue'])
0.17