CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-spreg

Spatial econometric regression models for analyzing geographically-related data interactions.

Overall
score

87%

Overview
Eval results
Files

task.mdevals/scenario-9/

Housing Price Spatial Analysis Tool

A tool for analyzing housing price data to detect spatial patterns and dependencies using diagnostic tests.

Problem Description

You are building a data analysis tool that helps urban planners and economists determine whether housing prices in a region exhibit spatial patterns. Specifically, the tool should run an initial regression analysis and then perform diagnostic tests to determine if:

  1. There is spatial autocorrelation in the regression errors (suggesting omitted spatially correlated variables)
  2. There is spatial dependence in the dependent variable itself (suggesting spillover effects)

The tool should provide clear recommendations based on the test results about which spatial model specifications might be appropriate for the data.

Requirements

Input Data

The tool should accept:

  • A dependent variable (y): housing prices
  • Independent variables (X): property characteristics (e.g., square footage, number of bedrooms, age)
  • A spatial weights matrix (W): defining the neighborhood structure between properties

Analysis Workflow

  1. Initial Regression: Run an ordinary least squares regression of housing prices on property characteristics
  2. Spatial Diagnostics: Perform diagnostic tests to detect spatial patterns in the regression
  3. Interpretation: Output test results with statistical significance and recommendations

Required Output

The tool should report:

  • Test statistics and p-values for spatial error tests
  • Test statistics and p-values for spatial lag tests
  • Recommendations on whether spatial models are needed based on conventional significance levels (α = 0.05)

Test Cases

  • Given a dataset with no spatial patterns, the tool reports that spatial models are not needed @test
  • Given a dataset with spatial error autocorrelation, the tool detects significant spatial error patterns @test
  • Given a dataset with spatial lag dependence, the tool detects significant spatial lag patterns @test

Implementation

@generates

API

def analyze_spatial_patterns(y, X, w):
    """
    Analyzes housing price data for spatial patterns using diagnostic tests.

    Parameters
    ----------
    y : numpy.ndarray
        Dependent variable (housing prices), shape (n, 1)
    X : numpy.ndarray
        Independent variables (property characteristics), shape (n, k)
    w : object
        Spatial weights matrix defining neighborhood relationships

    Returns
    -------
    dict
        Dictionary containing:
        - 'error_test': dict with 'statistic' and 'p_value' for spatial error test
        - 'lag_test': dict with 'statistic' and 'p_value' for spatial lag test
        - 'recommendation': string describing which spatial model (if any) is appropriate
    """
    pass

Dependencies { .dependencies }

spreg { .dependency }

Provides spatial econometric regression and diagnostic testing capabilities.

numpy { .dependency }

Provides array data structures and numerical operations.

Install with Tessl CLI

npx tessl i tessl/pypi-spreg

tile.json