pointpats.jacquez

pointpats.jacquez(s_coords, t_coords, k, permutations=99)[source]

Jacquez k nearest neighbors test for spatio-temporal interaction. [Jac96]

Parameters:
s_coordsarray

(n, 2), spatial coordinates.

t_coordsarray

(n, 1), temporal coordinates.

kint

the number of nearest neighbors to be searched.

permutationsint, optional

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

Returns:
jacquez_resultdictionary

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

statfloat

value of the Jacquez k nearest neighbors test for the dataset.

pvaluefloat

p-value associated with the statistic (normally distributed with k-1 df).

Examples

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

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

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

The Jacquez test counts the number of events that are k nearest neighbors in both time and space. The following runs the Jacquez test on the example data and reports the resulting statistic. In this case, there are 12 instances where events are nearest neighbors in both space and time. # turning off as kdtree changes from scipy < 0.12 return 13

>>> np.random.seed(100)
>>> result = jacquez(events.space, events.t ,k=3,permutations=99)
>>> print(result['stat'])
12

The significance of this can be assessed by calling the p- value from the results dictionary, as shown below. Again, no space-time interaction is observed.

>>> result['pvalue'] < 0.01
False