learn_spatial_weights

learn_spatial_weights(side=12, rho=0.6, k=4, permutations=199, seed=0)

See how the choice of spatial weights changes what “neighbors” means.

Simulates one field with dependence rho under queen contiguity (the true graph), then re-tests the same field under queen, rook and k-nearest-neighbor weights. All three detect the clustering, but the statistic shifts with the graph — the substantive conclusion should not hinge on one W, which is why :func:geometrics.analyze_spatial_model_by_weights exists.

Parameters

Name Type Description Default
side int Lattice side length (n = side²). 12
rho float Planted spatial dependence under the queen graph, |ρ| < 1. 0.6
k int Neighbors for the k-nearest-neighbor variant. 4
permutations int Conditional permutations behind each pseudo p-value. 199
seed int Random seed. 0

Returns

Name Type Description
SandboxResult df (one row per weights choice), fig, summary, topic and the simulated field in data.

Examples

import geometrics as gm

res = gm.learn_spatial_weights(rho=0.6, k=8)
res.df