tessl install tessl/pypi-spreg@1.8.0Spatial econometric regression models for analyzing geographically-related data interactions.
Agent Success
Agent success rate when using this tile
87%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.95x
Baseline
Agent success rate without this tile
92%
Build a tool that estimates spatial multiplier effects to decompose how changes in independent variables propagate through spatially connected observations. The tool should fit a spatial model and compute direct, indirect, and total effects.
Your implementation must accept:
Estimate a spatial lag model that includes a spatially lagged dependent variable. The model should:
Compute spatial multipliers that decompose the total effect into:
Calculate these multipliers using at least two different computational methods and verify they produce consistent results.
Return a data structure containing:
Given a 5-observation dataset with y=[1,2,3,4,5], X=[[1,2],[2,3],[3,4],[4,5],[5,6]], and a row-standardized spatial weights matrix with nearest-neighbor connections:
Using the same dataset from Test Case 1:
Using the fitted model from Test Case 1:
@generates
def analyze_spatial_multipliers(y, X, W):
"""
Estimate spatial multipliers from a spatial lag model.
Parameters:
-----------
y : array-like
Dependent variable (n x 1)
X : array-like
Independent variables (n x k)
W : array-like or sparse matrix
Spatial weights matrix (n x n)
Returns:
--------
dict
Dictionary containing:
- 'direct': array of direct effects for each variable
- 'indirect': array of indirect effects for each variable
- 'total': array of total effects for each variable
- 'methods': dict with results from different computation methods
- 'rho': estimated spatial autoregressive parameter
"""
passProvides spatial econometric regression models and multiplier computation.