Metadata-Version: 2.4
Name: nprobust
Version: 0.5.0
Summary: Nonparametric Robust Estimation and Inference Methods
Home-page: https://github.com/nppackages/nprobust
Author: Calonico, Cattaneo, and Farrell
License: GPL-2.0
Project-URL: Homepage, https://github.com/nppackages/nprobust
Project-URL: Repository, https://github.com/nppackages/nprobust
Project-URL: Documentation, https://nppackages.github.io/nprobust/
Keywords: nonparametric,regression,kernel density,bandwidth selection,robust inference,local polynomial
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.20.0
Requires-Dist: scipy>=1.7.0
Provides-Extra: plotting
Requires-Dist: matplotlib>=3.4.0; extra == "plotting"
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: matplotlib>=3.4.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: home-page
Dynamic: requires-python

# nprobust

Python implementation of the R package `nprobust`: Nonparametric Robust Estimation and Inference Methods using Local Polynomial Regression and Kernel Density Estimation.

## Description

This package provides tools for data-driven statistical analysis using local polynomial regression and kernel density estimation methods as described in:

- Calonico, Cattaneo and Farrell (2018): "On the Effect of Bias Estimation on Coverage Accuracy in Nonparametric Inference", *Journal of the American Statistical Association*.
- Calonico, Cattaneo and Farrell (2019): "nprobust: Nonparametric Kernel-Based Estimation and Robust Bias-Corrected Inference", *Journal of Statistical Software*.

## Installation

```bash
pip install nprobust .
```

Or with plotting support:


## Main Functions

- **lprobust**: Local polynomial point estimation and robust bias-corrected inference
- **lpbwselect**: Bandwidth selection for local polynomial regression
- **kdrobust**: Kernel density point estimation and robust bias-corrected inference
- **kdbwselect**: Bandwidth selection for kernel density estimation
- **nprobust_plot**: Plotting function for estimation results

## Basic Usage

```python
import numpy as np
from nprobust import lprobust, lpbwselect, kdrobust, kdbwselect, nprobust_plot

# Generate sample data
np.random.seed(42)
n = 500
x = np.random.uniform(0, 1, n)
y = np.sin(2 * np.pi * x) + np.random.normal(0, 0.5, n)

# Local polynomial regression
result = lprobust(y, x)
result.summary()

# Bandwidth selection
bw = lpbwselect(y, x, bwselect="mse-dpi")
bw.summary()

# Kernel density estimation
kd_result = kdrobust(x)
kd_result.summary()

# Plotting
fig = nprobust_plot(result, title="Local Polynomial Regression")
```

## Parameters

### lprobust

- `y`: Response variable
- `x`: Independent variable
- `eval`: Evaluation points (default: 30 equally spaced points)
- `p`: Polynomial order (default: 1)
- `deriv`: Order of derivative (default: 0)
- `h`: Bandwidth (default: data-driven selection)
- `kernel`: Kernel function ('epa', 'uni', 'tri', 'gau')
- `bwselect`: Bandwidth selection method ('mse-dpi', 'imse-dpi', etc.)
- `vce`: Variance estimator ('nn', 'hc0', 'hc1', 'hc2', 'hc3')

### kdrobust

- `x`: Data vector
- `eval`: Evaluation points
- `h`: Bandwidth
- `kernel`: Kernel function ('epa', 'uni', 'gau')
- `bwselect`: Bandwidth selection method

## References

- Calonico, S., M. D. Cattaneo, and M. H. Farrell (2018). "On the Effect of Bias Estimation on Coverage Accuracy in Nonparametric Inference." *Journal of the American Statistical Association* 113(522): 767-779.
- Calonico, S., M. D. Cattaneo, and M. H. Farrell (2019). "nprobust: Nonparametric Kernel-Based Estimation and Robust Bias-Corrected Inference." *Journal of Statistical Software* 91(8): 1-33.

## License

GPL-2

## Original R Package

https://github.com/nppackages/nprobust
