crabbymetrics

crabbymetrics logo

Rust-backed econometrics with NumPy arrays and a Python fit / predict / summary interface. This site documents v0.9.0.

Install and fit

pip install --upgrade crabbymetrics==0.9.0
import numpy as np
import crabbymetrics as cm

rng = np.random.default_rng(42)
x = rng.normal(size=(400, 2))
y = 0.5 + x @ np.array([1.0, -0.5]) + rng.normal(size=400)
model = cm.OLS()
model.fit(x, y)
result = model.summary(vcov="hc1")
print("Coefficients:", result["coef"])
print("Robust SE:", result["coef_se"])
print("Predictions:", model.predict(x[:3]))
Coefficients: [ 0.99250001 -0.5722471 ]
Robust SE: [0.05152025 0.0458896 ]
Predictions: [ 1.3856094   0.69463719 -0.7031842 ]

Pass finite NumPy arrays with the documented dtype and shape. Fits mutate the estimator in place; they do not return a fitted object. Summaries are dictionaries. The package’s only Python runtime dependency is NumPy.

Find an estimator

Task Reference Worked example
Linear regression and robust inference OLS, fixed effects, TwoSLS OLS, IV
Shrinkage and nonlinear prediction Ridge, ElasticNet, bagged polynomials Ridge tuning, feature pipelines
Binary, multiclass, and count outcomes Logit, MultinomialLogit, Poisson Prediction contracts
Event timing and recurrent events CoxPH, AndersenGill, WeibullPH Survival models
Treatment effects and balancing AIPW, DML, BalancingWeights, MPE_CBPS Double ML, Chronos LTV
Panel counterfactuals SyntheticDID, MatrixCompletion, AugmentedBalancing Staggered adoption
Dynamic treatment regimes RegressionBlip, ParallelTrendsSNMM, DynamicCovariateBalance Timing contracts and simulations
Custom moments or objectives GMM, MEstimator, Optimizers GMM, custom Poisson

The API overview lists all public classes, functions, and live signatures. The v0.9 migration guide covers changed numerical and inference behavior. A dense machine-readable guide is available in llms.txt.

Simulations and case studies

Implementation and reproduction

The OLS binding walkthrough, native Poisson solver, and MEstimator callback bridge explain how Python and Rust divide the work. See Rebuilding the docs for dependencies, data provenance, fresh simulation execution, and deployment checks.