Correcting inference in SAR models for rho-estimation uncertainty
Project description
rho-uncertainty
Correcting inference in spatial autoregressive (SAR) models for the estimation uncertainty in ρ.
The standard plug-in procedure treats ρ̂ as known, producing standard errors that are systematically too small. This package provides two corrections:
- VIF (instant, closed-form): captures 40-67% of the true correction
- SANI (seconds, numerical): captures ~98% of the true correction
Installation
pip install rho-uncertainty
Or download rho_uncertainty.py directly and place it in your working directory.
Usage with PySAL/spreg
from spreg import ML_Lag
model = ML_Lag(y, X, w=w)
from rho_uncertainty import correct
correct(model) # prints corrected regression table
correct(model, 'sani') # higher accuracy (~10s)
Usage with raw matrices
from rho_uncertainty import rho_test
# W: spatial weights (n x n), X: design matrix (n x p, with intercept)
# y: dependent variable (n,), rho_hat: estimated rho
result = rho_test(W, X, y, rho_hat=0.3)
Quick VIF-only correction
from rho_uncertainty import vif_correction
factor = vif_correction(W, X, rho_hat)
se_corrected = se_naive * factor
Example output
======================================================================
SAR Regression with Rho-Uncertainty Correction
======================================================================
Dependent variable: crime
n = 49, p = 3, rho_hat = 0.4159
Method: VIF
Variable Coef SE(naive) SE(VIF) t(VIF) p-value
-----------------------------------------------------------------
income 0.4795 0.1587 0.1597 3.0020 0.0043 ***
hoval -0.0760 0.1583 0.1589 -0.4784 0.6346
-----------------------------------------------------------------
Average variance inflation: +1.07%
======================================================================
How it works
The VIF captures only 40-67% of the true variance correction due to a structural limitation called phantom substitution. SANI bypasses this through Rao-Blackwellized numerical integration.
Requirements
- Python >= 3.8
- NumPy >= 1.20
- SciPy >= 1.7
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rho_uncertainty-0.1.1.tar.gz.
File metadata
- Download URL: rho_uncertainty-0.1.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ee177a4abce641b95b409680592e6b53f5fab1e46c6556f29ccb899f8a001e2
|
|
| MD5 |
d3271a16eaa00e4e8864cdc88d0cc698
|
|
| BLAKE2b-256 |
0a04a040927cd6e4130ae7096c0c5344859e367d41092bd8cd009f129b304c00
|
Provenance
The following attestation bundles were made for rho_uncertainty-0.1.1.tar.gz:
Publisher:
publish.yml on WillWeiQiang/rho-uncertainty
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rho_uncertainty-0.1.1.tar.gz -
Subject digest:
3ee177a4abce641b95b409680592e6b53f5fab1e46c6556f29ccb899f8a001e2 - Sigstore transparency entry: 1067028163
- Sigstore integration time:
-
Permalink:
WillWeiQiang/rho-uncertainty@25d965493429c5e5921ac58f89f214fa9a1d6e79 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/WillWeiQiang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@25d965493429c5e5921ac58f89f214fa9a1d6e79 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rho_uncertainty-0.1.1-py3-none-any.whl.
File metadata
- Download URL: rho_uncertainty-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d9922cf8c0652a98b4fa34517b8b1c8cf8c1c6da710684051ddf920c54ab3e4
|
|
| MD5 |
d481a6cf432a0915b92ac19b2bbeb307
|
|
| BLAKE2b-256 |
2fb9e7c82666cf2a057e6af565fcded53335514a7a959747e81d7d780a9295c1
|
Provenance
The following attestation bundles were made for rho_uncertainty-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on WillWeiQiang/rho-uncertainty
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rho_uncertainty-0.1.1-py3-none-any.whl -
Subject digest:
8d9922cf8c0652a98b4fa34517b8b1c8cf8c1c6da710684051ddf920c54ab3e4 - Sigstore transparency entry: 1067028262
- Sigstore integration time:
-
Permalink:
WillWeiQiang/rho-uncertainty@25d965493429c5e5921ac58f89f214fa9a1d6e79 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/WillWeiQiang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@25d965493429c5e5921ac58f89f214fa9a1d6e79 -
Trigger Event:
release
-
Statement type: