Spatial econometric regression models for analyzing geographically-related data interactions.
Overall
score
87%
Spatial probit regression for binary choice models with spatial dependence, supporting various spatial structures and diagnostic tests.
class Probit:
def __init__(self, y, x, w=None, optim='newton', scalem='phimean', maxiter=100,
vm=False, name_y=None, name_x=None, name_w=None, name_ds=None,
latex=False, hard_bound=False):
"""
Spatial probit regression for binary dependent variables.
Parameters:
- y (array): nx1 binary dependent variable (0/1)
- x (array): nxk independent variables
- w (sparse matrix, optional): Spatial weights for spatial probit
- optim (str): Optimization method ('newton' or 'bfgs')
- scalem (str): Scale method ('phimean' or 'xmean')
- maxiter (int): Maximum iterations for optimization
- vm (bool): Include variance-covariance matrix
- hard_bound (bool): Enforce spatial parameter bounds
Attributes:
- betas (array): Estimated coefficients
- rho (float): Spatial dependence parameter (if spatial)
- logl (float): Log-likelihood value
- predy (array): Predicted probabilities
- summary (str): Formatted results
"""import numpy as np
import spreg
# Binary dependent variable
n = 100
x = np.random.randn(n, 2)
linear_combo = 1 + x[:, 0] + 2 * x[:, 1] + np.random.randn(n)
y = (linear_combo > 0).astype(int).reshape(-1, 1)
# Probit estimation
probit_model = spreg.Probit(y, x, name_y='choice', name_x=['x1', 'x2'])
print(probit_model.summary)Install with Tessl CLI
npx tessl i tessl/pypi-spregdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10