or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/spreg@1.8.x
tile.json

tessl/pypi-spreg

tessl install tessl/pypi-spreg@1.8.0

Spatial 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%

task.mdevals/scenario-5/

Model Fit Evaluator

A tool for evaluating and comparing regression model fit quality using R-squared and pseudo R-squared metrics.

Capabilities

Compute standard R-squared for OLS model

Fits an OLS regression model and returns the R-squared value indicating the proportion of variance explained.

  • Given dependent variable y=[1, 2, 3, 4, 5], independent variable x=[[1], [2], [3], [4], [5]], returns R-squared equal to 1.0 @test

Compute adjusted R-squared for OLS model

Fits an OLS regression model and returns the adjusted R-squared which penalizes model complexity.

  • Given y=[10, 15, 13, 17, 20, 22], x=[[1, 2], [2, 3], [3, 1], [4, 2], [5, 4], [6, 3]], returns adjusted R-squared less than standard R-squared @test

Compute pseudo R-squared for TSLS model

Fits a two-stage least squares model with an endogenous variable and returns the pseudo R-squared metric.

  • Given y, x (exogenous), yend (endogenous), and q (instrument), returns pseudo R-squared value between 0 and 1 @test

Compare model fit between OLS and TSLS

Evaluates both OLS and TSLS models on the same data and compares their fit metrics.

  • Given the same y and x data, fits OLS with R-squared and TSLS with pseudo R-squared, returns both metrics for comparison @test

Implementation

@generates

API

def compute_ols_fit(y, x):
    """
    Compute R-squared and adjusted R-squared for an OLS regression model.

    Parameters:
    - y (array): nx1 dependent variable
    - x (array): nxk independent variables

    Returns:
    - dict: {'r_squared': float, 'adjusted_r_squared': float}
    """

def compute_tsls_fit(y, x, yend, q):
    """
    Compute pseudo R-squared for a two-stage least squares model.

    Parameters:
    - y (array): nx1 dependent variable
    - x (array): nxk exogenous independent variables
    - yend (array): nxp endogenous variables
    - q (array): nxq external instruments

    Returns:
    - float: Pseudo R-squared value
    """

def compare_models(y, x, yend=None, q=None):
    """
    Compare OLS and TSLS model fit on the same dataset.

    Parameters:
    - y (array): nx1 dependent variable
    - x (array): nxk independent variables
    - yend (array, optional): nxp endogenous variables for TSLS
    - q (array, optional): nxq instruments for TSLS

    Returns:
    - dict: {'ols': {'r_squared': float, 'adjusted_r_squared': float},
             'tsls': {'pseudo_r_squared': float}} if yend and q provided,
             otherwise only returns 'ols' results
    """

Dependencies { .dependencies }

spreg { .dependency }

Provides spatial econometric regression models including OLS and TSLS estimation with fit statistics.

@satisfied-by