Skip to content

ENH: Method for building Spatiotemporal Graphs #873

@FirePheonix

Description

@FirePheonix

As discussed in
GWLearn's issue: pysal/gwlearn#69

To perform spatiotemporal regression (GTWR), users currently have to manually build separate spatial and temporal graphs, intersect them, and handle the weight multiplication themselves. This is very complicated.

There's a need for adding a first class method to handle spatio-temporal weight construction.
We can likely use the "Product of Kernels" approach ($W_{ST} = W_S \times W_T$). This allows independent bandwidths for space and time.
Few options I'd like to mention (totally open for more, for a more cleaner API)

  1. Graph.build_spatiotemporal
    A dedicated constructor that takes both spatial and temporal data.
st_graph = Graph.build_spatiotemporal(
    gdf, 
    t_values, 
    spatial_k=50, 
    temporal_bandwidth=365
)
  1. Hadamard Product (Graph.multiply)
    A more general method that allows scaling weights of one graph by those of another (assuming matching edges/indices).
spatial_graph = Graph.build_knn(gdf, k=50)
temporal_graph = Graph.build_kernel(t_values, bandwidth=365)
st_graph = spatial_graph.multiply(temporal_graph)

Moving this to libpysal ensures:

A clean, "PySAL-ic" API that favors composition.
Cross-package compatibility (e.g., gwlearn and esda can both use the same ST graph logic). Libraries like gwlearn or esda can focus on modeling/statistics rather than.. having an unnecessary graph intersection logics

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions