The rbbnp package implements a novel bias-bound approach to nonparametric inference developed by Schennach (2020). The key insight is that while we cannot consistently estimate pointwise bias, we can estimate an upper bound on bias magnitude, enabling valid confidence intervals with optimal bandwidths.
Traditional nonparametric inference faces a dilemma:
The bias-bound approach constructs confidence intervals that explicitly account for potential bias:
\[CI = [\hat{f} - \bar{b} - z_{\alpha/2}\hat{\sigma}, \quad \hat{f} + \bar{b} + z_{\alpha/2}\hat{\sigma}]\]
where \(\bar{b}\) is the estimated bias bound.
# Generate sample data
X <- gen_sample_data(size = 500, dgp = "2_fold_uniform", seed = 123456)
# Estimate density with bias-aware confidence intervals
fit <- biasBound_density(X, h = 0.1, kernel.fun = "Schennach2004")
# View summary
fit
#> Bias-Bounded Density Estimation
#>
#> Call:
#> biasBound_density(X = X, h = 0.1, kernel.fun = "Schennach2004")
#>
#> Sample size: n = 500
#> Bandwidth: h = 0.1000 (user-specified)
#> Kernel: Schennach2004
#>
#> Bias bound parameters:
#> A = 6.3312, r = 2.3422
#> bias bound b1x = 0.0714
#>
#> Evaluation points: 100 (range: [-0.1639, 2.0517])
#> Confidence level: 95%
#>
#> Use summary() for detailed statistics
#> Use plot() to visualize resultsThe plot shows (the legend labels each element):
Both functions return S3 objects with standard methods:
# Extract parameters
coef(fit)
#> A r h
#> 6.3312 2.3422 0.1000
# Get confidence intervals
head(confint(fit))
#> lower upper
#> [1,] 0 0.07139636
#> [2,] 0 0.07139636
#> [3,] 0 0.07139636
#> [4,] 0 0.07139636
#> [5,] 0 0.08205420
#> [6,] 0 0.09605150
# For regression: get fitted values
head(fitted(fit_reg))
#> [1] 0.0420927 0.1386661 0.2211023 0.2938845 0.3597238 0.4202832Schennach, S. M. (2020). A Bias Bound Approach to Non-parametric Inference. The Review of Economic Studies, 87(5), 2439-2472. doi:10.1093/restud/rdz065