pointpats.mantel

pointpats.mantel(s_coords, t_coords, permutations=99, scon=1.0, spow=-1.0, tcon=1.0, tpow=-1.0)[source]

Standardized Mantel test for spatio-temporal interaction. [Man67]

Parameters:
s_coordsarray

(n, 2), spatial coordinates.

t_coordsarray

(n, 1), temporal coordinates.

permutationsint, optional

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

sconfloat, optional

constant added to spatial distances (the default is 1.0).

spowfloat, optional

value for power transformation for spatial distances (the default is -1.0).

tconfloat, optional

constant added to temporal distances (the default is 1.0).

tpowfloat, optional

value for power transformation for temporal distances (the default is -1.0).

Returns:
mantel_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.

Examples

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

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)

The standardized Mantel test is a measure of matrix correlation between the spatial and temporal distance matrices of the event dataset. The following example runs the standardized Mantel test without a constant or transformation; however, as recommended by [Man67], these should be added by the user. This can be done by adjusting the constant and power parameters.

>>> result = mantel(events.space, events.t, 99, scon=1.0, spow=-1.0, tcon=1.0, tpow=-1.0)

Next, we examine the result of the test.

>>> print("%6.6f"%result['stat'])
0.048368

Finally, we look at the pseudo-significance of this value, calculated by permuting the timestamps and rerunning the statistic for each of the 99 permutations. According to these parameters, the results indicate space-time interaction between the events.

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