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-5/

Multi-Equation Economic System Estimator

A tool for estimating systems of related economic equations with potentially correlated errors using Seemingly Unrelated Regression (SUR).

Problem Description

You need to build a system that can estimate multiple related regression equations simultaneously. The system should handle cases where the error terms across equations may be correlated, which makes joint estimation more efficient than separate equation-by-equation estimation.

Your implementation should support:

  • Estimating a system of two or more equations
  • Accepting data organized by equation (each equation has its own dependent and independent variables)
  • Returning coefficient estimates for all equations
  • Providing standard errors for the estimated coefficients
  • Computing measures of model fit

Capabilities

Basic SUR Estimation

  • Given data for two equations with uncorrelated errors, estimates coefficients for both equations @test
  • Given data for three equations, successfully estimates all equation coefficients @test
  • Returns coefficient standard errors for all equations @test

Model Fit Assessment

  • Computes and returns R-squared values for each equation in the system @test
  • Provides log-likelihood value for the estimated system @test

Implementation

@generates

API

def estimate_sur_system(equation_data: dict) -> dict:
    """
    Estimates a system of seemingly unrelated regression equations.

    Parameters
    ----------
    equation_data : dict
        Dictionary where keys are equation names and values are dicts containing:
        - 'y': numpy array of dependent variable (n x 1)
        - 'x': numpy array of independent variables (n x k)

    Returns
    -------
    dict
        Dictionary containing:
        - 'coefficients': dict mapping equation names to coefficient arrays
        - 'std_errors': dict mapping equation names to standard error arrays
        - 'r_squared': dict mapping equation names to R-squared values
        - 'log_likelihood': float, log-likelihood of the system

    Examples
    --------
    >>> import numpy as np
    >>> data = {
    ...     'eq1': {'y': np.array([[1], [2], [3]]),
    ...             'x': np.array([[1, 2], [1, 3], [1, 4]])},
    ...     'eq2': {'y': np.array([[2], [4], [6]]),
    ...             'x': np.array([[1, 1], [1, 2], [1, 3]])}
    ... }
    >>> results = estimate_sur_system(data)
    >>> results['coefficients']['eq1']
    array([...])
    """
    pass

Dependencies { .dependencies }

spreg { .dependency }

Provides spatial econometric regression models including SUR estimation.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-spreg

tile.json